diff --git a/functions/sockets.xml b/functions/sockets.xml index c9bf2d9f3e..1ff5c06da5 100644 --- a/functions/sockets.xml +++ b/functions/sockets.xml @@ -1,5 +1,5 @@ - + Socket functions Sockets @@ -76,13 +76,12 @@ do { break; } do { - $buf = ''; - $ret = socket_read ($msgsock, $buf, 2048); - if ($ret < 0) { + $buf = socket_read ($msgsock, 2048); + if ($buf == FALSE) { echo "socket_read() failed: reason: " . socket_strerror ($ret) . "\n"; break 2; } - if ($ret == 0) { + if (!$buf) { break 2; } $buf = trim ($buf); @@ -148,7 +147,7 @@ socket_write ($socket, $in, strlen ($in)); echo "OK.\n"; echo "Reading response:\n\n"; -while (socket_read ($socket, $out, 2048)) { +while ($out = socket_read ($socket, 2048)) { echo $out; } @@ -411,13 +410,13 @@ echo "OK.\n\n"; socket_read - Read from a socket + Reads from a socket Description - int socket_read + mixed socket_read resource socket_des int length int type @@ -429,7 +428,8 @@ echo "OK.\n\n"; socket_des created by the socket_accept function the number of bytes set by length. Otherwise you can use \n, \t or \0 to - end reading. Returns the bytes that were read. + end reading. Returns data, or FALSE if + socket_read failed. Optional type parameter is a named constant: