#21197 [Opn]: socket_read() outputs error with PHP_NORMAL_READ
ID: 21197 Updated by: [EMAIL PROTECTED] Reported By: bool at boolsite dot net Status: Open Bug Type: Sockets related Operating System: * PHP Version: 5.*, 4.* (2005-10-29) (snap) New Comment: I've made a patch that implements the idea of my last comment. The test case now works properly. I haven't tested bug #35062 but it seems to be a different bug. http://mega.ist.utl.pt/~ncpl/php_sockets_win.txt Previous Comments: [2005-11-05 01:36:39] [EMAIL PROTECTED] I was walking through the MSDN docs and I didn't also find anything. But the best way (IMHO) is to store in the php_socket struct if the socket is blocking or not (and update that field in the socket_set_(non)block() functions). It also saves the fcntl syscall on nix systems. [2005-11-04 19:30:44] [EMAIL PROTECTED] Here's a possible patch, but Wez probably knows better if there's a way to tell if a windows socket is in blocking mode... Index: sockets.c === RCS file: /repository/php-src/ext/sockets/sockets.c,v retrieving revision 1.171.2.2 diff -u -p -d -r1.171.2.2 sockets.c --- sockets.c 3 Nov 2005 15:00:51 - 1.171.2.2 +++ sockets.c 4 Nov 2005 18:28:45 - @@ -257,6 +257,12 @@ static int php_read(int bsd_socket, void int nonblock = 0; char *t = (char *) buf; +/* + * fcntl(s, F_GETFL) will always fail for windows, and there's no way to + * determine if a socket is in blocking mode to my current knowledge, so we + * just omit this check; though that means we're always blocking on win32... + */ +#ifndef PHP_WIN32 m = fcntl(bsd_socket, F_GETFL); if (m 0) { return m; @@ -264,6 +270,7 @@ static int php_read(int bsd_socket, void nonblock = (m O_NONBLOCK); m = 0; +#endif set_errno(0); [2005-11-04 16:24:47] [EMAIL PROTECTED] See also bug #35062 [2005-09-29 16:07:34] tommyo at gmail dot com I installed the latest windows build PHP Version 5.1.0RC2-dev and the socket problem still exists. I get: Warning: socket_read() [function.socket-read]: unable to read from socket [0]: The operation completed successfully. When I put PHP_NORMAL_READ for the read type parameter. Using the default or PHP_BINARY_READ works just fine for the same line of code. [2004-03-11 11:06:02] [EMAIL PROTECTED] I've compilled PHP with cygwin/gcc and no error is produced. However, the build version from snaps.php.net gives that error. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21197 -- Edit this bug report at http://bugs.php.net/?id=21197edit=1
#21197 [Opn]: socket_read() outputs error with PHP_NORMAL_READ
ID: 21197 Updated by: [EMAIL PROTECTED] Reported By: bool at boolsite dot net Status: Open Bug Type: Sockets related Operating System: * PHP Version: 5.*, 4.* (2005-10-29) (snap) New Comment: See also bug #35062 Previous Comments: [2005-09-29 16:07:34] tommyo at gmail dot com I installed the latest windows build PHP Version 5.1.0RC2-dev and the socket problem still exists. I get: Warning: socket_read() [function.socket-read]: unable to read from socket [0]: The operation completed successfully. When I put PHP_NORMAL_READ for the read type parameter. Using the default or PHP_BINARY_READ works just fine for the same line of code. [2004-03-11 11:06:02] [EMAIL PROTECTED] I've compilled PHP with cygwin/gcc and no error is produced. However, the build version from snaps.php.net gives that error. [2003-08-26 02:00:58] bool at boolsite dot net Ok, this is a short example : (a little echo server) ?php error_reporting(E_ALL); $Port=6669; if(($Sock=socket_create(AF_INET,SOCK_STREAM,0))=0) { echo 'socket_create() a échoué : ',socket_strerror(socket_last_error($Sock)),\r\n; exit; } if(($Ret=socket_bind($Sock,0,$Port))=0) { echo 'socket_bind() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } if(($Ret=socket_listen($Sock,5))=0) { echo 'socket_listen() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } while(true){ $MsgSock=socket_accept($Sock); if($MsgSock===false) { echo 'socket_accept() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } else { echo '= Debut de la connexion...',\r\n; $EndTime=time()+15; do{ $buffer=socket_read($MsgSock,1024,PHP_NORMAL_READ); if($buffer===false) { echo 'socket_read() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } elseif(!$buffer){ continue; } $buffer=trim($buffer); echo ' ',$buffer,\r\n; if($buffer=='quit') { break; } $back='You sent : ['.$buffer.']'; echo ' ',$back,\r\n; socket_write($MsgSock,$back.\r\n); } while(time()$EndTime); @socket_close($MsgSock); echo '= End...',\r\n; } } socket_close($Sock); ? [2002-12-26 20:39:22] [EMAIL PROTECTED] If you omit the third parameter to socket_read() it seems to work fine. However, adding PHP_NORMAL_READ causes error as described in the bug report. [2002-12-26 09:32:25] bool at boolsite dot net Hello I have a source which works with PHP 4.1.x to PHP 4.2.x, it's work perfectly. But with PHP 4.3RC4 (windows version, client mode) I have this warning : Warning: socket_read() unable to read from socket [0]: OpÚration rÚussie. in E:\PHP\KioobFTP\v0.7.1\KioobFTP_SocketMode.php on line 262 Then, the result of the function is FALSE. The socket is in blocking mode. The code is : $tmp=socket_read($this-stream,4096,PHP_NORMAL_READ); Do you need others info ? Thanks. Bool -- Edit this bug report at http://bugs.php.net/?id=21197edit=1
#21197 [Opn]: socket_read() outputs error with PHP_NORMAL_READ
ID: 21197 Updated by: [EMAIL PROTECTED] Reported By: bool at boolsite dot net Status: Open Bug Type: Sockets related Operating System: * PHP Version: 5.*, 4.* (2005-10-29) (snap) New Comment: Here's a possible patch, but Wez probably knows better if there's a way to tell if a windows socket is in blocking mode... Index: sockets.c === RCS file: /repository/php-src/ext/sockets/sockets.c,v retrieving revision 1.171.2.2 diff -u -p -d -r1.171.2.2 sockets.c --- sockets.c 3 Nov 2005 15:00:51 - 1.171.2.2 +++ sockets.c 4 Nov 2005 18:28:45 - @@ -257,6 +257,12 @@ static int php_read(int bsd_socket, void int nonblock = 0; char *t = (char *) buf; +/* + * fcntl(s, F_GETFL) will always fail for windows, and there's no way to + * determine if a socket is in blocking mode to my current knowledge, so we + * just omit this check; though that means we're always blocking on win32... + */ +#ifndef PHP_WIN32 m = fcntl(bsd_socket, F_GETFL); if (m 0) { return m; @@ -264,6 +270,7 @@ static int php_read(int bsd_socket, void nonblock = (m O_NONBLOCK); m = 0; +#endif set_errno(0); Previous Comments: [2005-11-04 16:24:47] [EMAIL PROTECTED] See also bug #35062 [2005-09-29 16:07:34] tommyo at gmail dot com I installed the latest windows build PHP Version 5.1.0RC2-dev and the socket problem still exists. I get: Warning: socket_read() [function.socket-read]: unable to read from socket [0]: The operation completed successfully. When I put PHP_NORMAL_READ for the read type parameter. Using the default or PHP_BINARY_READ works just fine for the same line of code. [2004-03-11 11:06:02] [EMAIL PROTECTED] I've compilled PHP with cygwin/gcc and no error is produced. However, the build version from snaps.php.net gives that error. [2003-08-26 02:00:58] bool at boolsite dot net Ok, this is a short example : (a little echo server) ?php error_reporting(E_ALL); $Port=6669; if(($Sock=socket_create(AF_INET,SOCK_STREAM,0))=0) { echo 'socket_create() a échoué : ',socket_strerror(socket_last_error($Sock)),\r\n; exit; } if(($Ret=socket_bind($Sock,0,$Port))=0) { echo 'socket_bind() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } if(($Ret=socket_listen($Sock,5))=0) { echo 'socket_listen() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } while(true){ $MsgSock=socket_accept($Sock); if($MsgSock===false) { echo 'socket_accept() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } else { echo '= Debut de la connexion...',\r\n; $EndTime=time()+15; do{ $buffer=socket_read($MsgSock,1024,PHP_NORMAL_READ); if($buffer===false) { echo 'socket_read() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } elseif(!$buffer){ continue; } $buffer=trim($buffer); echo ' ',$buffer,\r\n; if($buffer=='quit') { break; } $back='You sent : ['.$buffer.']'; echo ' ',$back,\r\n; socket_write($MsgSock,$back.\r\n); } while(time()$EndTime); @socket_close($MsgSock); echo '= End...',\r\n; } } socket_close($Sock); ? [2002-12-26 20:39:22] [EMAIL PROTECTED] If you omit the third parameter to socket_read() it seems to work fine. However, adding PHP_NORMAL_READ causes error as described in the bug report. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21197 -- Edit this bug report at http://bugs.php.net/?id=21197edit=1
#21197 [Opn]: socket_read() outputs error with PHP_NORMAL_READ
ID: 21197 Updated by: [EMAIL PROTECTED] Reported By: bool at boolsite dot net Status: Open Bug Type: Sockets related Operating System: * PHP Version: 5.*, 4.* (2005-10-29) (snap) New Comment: I was walking through the MSDN docs and I didn't also find anything. But the best way (IMHO) is to store in the php_socket struct if the socket is blocking or not (and update that field in the socket_set_(non)block() functions). It also saves the fcntl syscall on nix systems. Previous Comments: [2005-11-04 19:30:44] [EMAIL PROTECTED] Here's a possible patch, but Wez probably knows better if there's a way to tell if a windows socket is in blocking mode... Index: sockets.c === RCS file: /repository/php-src/ext/sockets/sockets.c,v retrieving revision 1.171.2.2 diff -u -p -d -r1.171.2.2 sockets.c --- sockets.c 3 Nov 2005 15:00:51 - 1.171.2.2 +++ sockets.c 4 Nov 2005 18:28:45 - @@ -257,6 +257,12 @@ static int php_read(int bsd_socket, void int nonblock = 0; char *t = (char *) buf; +/* + * fcntl(s, F_GETFL) will always fail for windows, and there's no way to + * determine if a socket is in blocking mode to my current knowledge, so we + * just omit this check; though that means we're always blocking on win32... + */ +#ifndef PHP_WIN32 m = fcntl(bsd_socket, F_GETFL); if (m 0) { return m; @@ -264,6 +270,7 @@ static int php_read(int bsd_socket, void nonblock = (m O_NONBLOCK); m = 0; +#endif set_errno(0); [2005-11-04 16:24:47] [EMAIL PROTECTED] See also bug #35062 [2005-09-29 16:07:34] tommyo at gmail dot com I installed the latest windows build PHP Version 5.1.0RC2-dev and the socket problem still exists. I get: Warning: socket_read() [function.socket-read]: unable to read from socket [0]: The operation completed successfully. When I put PHP_NORMAL_READ for the read type parameter. Using the default or PHP_BINARY_READ works just fine for the same line of code. [2004-03-11 11:06:02] [EMAIL PROTECTED] I've compilled PHP with cygwin/gcc and no error is produced. However, the build version from snaps.php.net gives that error. [2003-08-26 02:00:58] bool at boolsite dot net Ok, this is a short example : (a little echo server) ?php error_reporting(E_ALL); $Port=6669; if(($Sock=socket_create(AF_INET,SOCK_STREAM,0))=0) { echo 'socket_create() a échoué : ',socket_strerror(socket_last_error($Sock)),\r\n; exit; } if(($Ret=socket_bind($Sock,0,$Port))=0) { echo 'socket_bind() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } if(($Ret=socket_listen($Sock,5))=0) { echo 'socket_listen() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } while(true){ $MsgSock=socket_accept($Sock); if($MsgSock===false) { echo 'socket_accept() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } else { echo '= Debut de la connexion...',\r\n; $EndTime=time()+15; do{ $buffer=socket_read($MsgSock,1024,PHP_NORMAL_READ); if($buffer===false) { echo 'socket_read() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } elseif(!$buffer){ continue; } $buffer=trim($buffer); echo ' ',$buffer,\r\n; if($buffer=='quit') { break; } $back='You sent : ['.$buffer.']'; echo ' ',$back,\r\n; socket_write($MsgSock,$back.\r\n); } while(time()$EndTime); @socket_close($MsgSock); echo '= End...',\r\n; } } socket_close($Sock); ? The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21197 -- Edit this bug report at http://bugs.php.net/?id=21197edit=1
#21197 [Opn]: socket_read() outputs error with PHP_NORMAL_READ
ID: 21197 User updated by: bool at boolsite dot net Reported By: bool at boolsite dot net Status: Open Bug Type: Sockets related Operating System: win32 only PHP Version: 5.*, 4.* New Comment: With PHP 5 you can use the Stream extension (http://www.php.net/manual/en/ref.stream.php), which works well and is not experimental. Previous Comments: [2005-09-29 16:07:34] tommyo at gmail dot com I installed the latest windows build PHP Version 5.1.0RC2-dev and the socket problem still exists. I get: Warning: socket_read() [function.socket-read]: unable to read from socket [0]: The operation completed successfully. When I put PHP_NORMAL_READ for the read type parameter. Using the default or PHP_BINARY_READ works just fine for the same line of code. [2005-09-29 01:00:25] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to Open. [2005-09-21 12:46:05] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip [2004-03-11 11:06:02] [EMAIL PROTECTED] I've compilled PHP with cygwin/gcc and no error is produced. However, the build version from snaps.php.net gives that error. [2003-08-26 02:00:58] bool at boolsite dot net Ok, this is a short example : (a little echo server) ?php error_reporting(E_ALL); $Port=6669; if(($Sock=socket_create(AF_INET,SOCK_STREAM,0))=0) { echo 'socket_create() a échoué : ',socket_strerror(socket_last_error($Sock)),\r\n; exit; } if(($Ret=socket_bind($Sock,0,$Port))=0) { echo 'socket_bind() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } if(($Ret=socket_listen($Sock,5))=0) { echo 'socket_listen() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } while(true){ $MsgSock=socket_accept($Sock); if($MsgSock===false) { echo 'socket_accept() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } else { echo '= Debut de la connexion...',\r\n; $EndTime=time()+15; do{ $buffer=socket_read($MsgSock,1024,PHP_NORMAL_READ); if($buffer===false) { echo 'socket_read() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } elseif(!$buffer){ continue; } $buffer=trim($buffer); echo ' ',$buffer,\r\n; if($buffer=='quit') { break; } $back='You sent : ['.$buffer.']'; echo ' ',$back,\r\n; socket_write($MsgSock,$back.\r\n); } while(time()$EndTime); @socket_close($MsgSock); echo '= End...',\r\n; } } socket_close($Sock); ? The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21197 -- Edit this bug report at http://bugs.php.net/?id=21197edit=1
#21197 [Opn]: socket_read() outputs error with PHP_NORMAL_READ
ID: 21197 Updated by: [EMAIL PROTECTED] Reported By: bool at boolsite dot net Status: Open Bug Type: Sockets related Operating System: win32 only PHP Version: php 4.3.5RC4-dev Assigned To: wez New Comment: I've compilled PHP with cygwin/gcc and no error is produced. However, the build version from snaps.php.net gives that error. Previous Comments: [2004-02-27 16:54:38] [EMAIL PROTECTED] Using latest PHP 5 snapshot and I still receive the error. [2004-02-25 18:54:27] bool at boolsite dot net it's again the same thing : X-Powered-By: PHP/4.3.5RC4-dev erreur [0] avec socket_read : OpÚration rÚussie. [2004-02-25 18:38:44] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip Bug #21760 was fixed, and it's pretty likely this is the same issue. [2004-01-10 20:30:41] [EMAIL PROTECTED] Assigning to Wez who might know why streams are borked. [2003-12-15 11:11:42] nunoplopes at sapo dot pt I'm using latest snapshot and I have the same problem. With PHP_BINARY_READ everything works but with PHP_NORMAL_READ I receive the following error: Warning: socket_read() unable to read from socket [0]: The operation completed s uccessfully. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21197 -- Edit this bug report at http://bugs.php.net/?id=21197edit=1
#21197 [Opn]: socket_read() outputs error with PHP_NORMAL_READ
ID: 21197 Updated by: [EMAIL PROTECTED] Reported By: bool at boolsite dot net Status: Open Bug Type: Sockets related Operating System: win32 only PHP Version: php 4.3.5RC4-dev Assigned To: wez New Comment: Using latest PHP 5 snapshot and I still receive the error. Previous Comments: [2004-02-25 18:54:27] bool at boolsite dot net it's again the same thing : X-Powered-By: PHP/4.3.5RC4-dev erreur [0] avec socket_read : OpÚration rÚussie. [2004-02-25 18:38:44] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip Bug #21760 was fixed, and it's pretty likely this is the same issue. [2004-01-10 20:30:41] [EMAIL PROTECTED] Assigning to Wez who might know why streams are borked. [2003-12-15 11:11:42] nunoplopes at sapo dot pt I'm using latest snapshot and I have the same problem. With PHP_BINARY_READ everything works but with PHP_NORMAL_READ I receive the following error: Warning: socket_read() unable to read from socket [0]: The operation completed s uccessfully. [2003-08-26 02:00:58] bool at boolsite dot net Ok, this is a short example : (a little echo server) ?php error_reporting(E_ALL); $Port=6669; if(($Sock=socket_create(AF_INET,SOCK_STREAM,0))=0) { echo 'socket_create() a échoué : ',socket_strerror(socket_last_error($Sock)),\r\n; exit; } if(($Ret=socket_bind($Sock,0,$Port))=0) { echo 'socket_bind() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } if(($Ret=socket_listen($Sock,5))=0) { echo 'socket_listen() a échoué : ',socket_strerror(socket_last_error($Ret)),\r\n; exit; } while(true){ $MsgSock=socket_accept($Sock); if($MsgSock===false) { echo 'socket_accept() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } else { echo '= Debut de la connexion...',\r\n; $EndTime=time()+15; do{ $buffer=socket_read($MsgSock,1024,PHP_NORMAL_READ); if($buffer===false) { echo 'socket_read() a échoué : ',socket_strerror(socket_last_error($MsgSock)),\r\n; break; } elseif(!$buffer){ continue; } $buffer=trim($buffer); echo ' ',$buffer,\r\n; if($buffer=='quit') { break; } $back='You sent : ['.$buffer.']'; echo ' ',$back,\r\n; socket_write($MsgSock,$back.\r\n); } while(time()$EndTime); @socket_close($MsgSock); echo '= End...',\r\n; } } socket_close($Sock); ? The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21197 -- Edit this bug report at http://bugs.php.net/?id=21197edit=1