#45514 [Fbk->Opn]: socket_select + timeout returns immediately on non-blocking connect
ID: 45514 User updated by: rbarnes at aethon dot com Reported By: rbarnes at aethon dot com -Status: Feedback +Status: Open Bug Type: Sockets related Operating System: Ubuntu 7.10 / Linux 2.6.22-14 PHP Version: 5.2.6 New Comment: Interesting. I'll probably be moving back to Israel in a few months and I might be interested in getting involved in the sockets code as it's an area of interest for me. Are you guys looking for someone and if so how would that work? Previous Comments: [2008-07-15 17:16:36] [EMAIL PROTECTED] Well, in one other report about basically same issue the comments were along the lines of "ext/sockets" being "deprecated" and the stream_* stuff being the suggested way to get working solution. Don't hold your breath waiting for anything getting fixed in ext/sockets, there's no maintainer for that. -------- [2008-07-15 15:20:43] rbarnes at aethon dot com Thanks for the tip, but the point of the bug report is that socket_select doesn't work properly. The fact that I could theoretically rewrite all of the networking code in my API to use the stream_* functions doesn't change the fact that socket_select is broken. I also already know of other ways to implement non-blocking connect with the socket_* functions, but as I said that also doesn't change the fact that this juk is bugging me. Yalla, fix it or mark the Berkley Sockets API deprecated ;-) [2008-07-15 13:06:10] [EMAIL PROTECTED] Try using stream_select() and the other stream_* functions instead: http://www.php.net/manual/en/ref.stream.php -------------------- [2008-07-14 21:58:01] rbarnes at aethon dot com Description: I'm trying to implement a non-blocking connect similar to the one in Steven's "Unix Network Programming" on pg 450. I create the socket, set it to non-blocking and call connect which of course returns immediately with a SOCKET_EINPROGRESS error ( as expected ). Then I call socket_select with a timeout greater than 0 and socket_select returns immediately, even though the socket's state is still SOCKET_EINPROGRESS. errno 115: Operation now in progress Reproduce code: --- function ConnectSocket($remote, $port) { $sock = NULL; if (!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) return NULL; socket_set_nonblock($sock); if ([EMAIL PROTECTED]($sock, $remote, $port+0)) { if (socket_select($rin = array($sock), $win = $rin, $ein = NULL, 30.0) < 1) return NULL; if (socket_recv($sock, $buf, 0, 0) === false) { print socket_strerror(socket_last_error()) . "\n"; return NULL; } } socket_set_block($sock); return $sock; } ConnectSocket('206.190.60.37', 80); Expected result: socket_select should block until either the connection completes or the timeout is exceeded. Actual result: -- socket_select returns immediately. SOCKET_EINPROGRESS Operation now in progress -- Edit this bug report at http://bugs.php.net/?id=45514&edit=1
#45514 [Fbk->Opn]: socket_select + timeout returns immediately on non-blocking connect
ID: 45514 User updated by: rbarnes at aethon dot com Reported By: rbarnes at aethon dot com -Status: Feedback +Status: Open Bug Type: Sockets related Operating System: Ubuntu 7.10 / Linux 2.6.22-14 PHP Version: 5.2.6 New Comment: Thanks for the tip, but the point of the bug report is that socket_select doesn't work properly. The fact that I could theoretically rewrite all of the networking code in my API to use the stream_* functions doesn't change the fact that socket_select is broken. I also already know of other ways to implement non-blocking connect with the socket_* functions, but as I said that also doesn't change the fact that this juk is bugging me. Yalla, fix it or mark the Berkley Sockets API deprecated ;-) Previous Comments: [2008-07-15 13:06:10] [EMAIL PROTECTED] Try using stream_select() and the other stream_* functions instead: http://www.php.net/manual/en/ref.stream.php [2008-07-14 21:58:01] rbarnes at aethon dot com Description: I'm trying to implement a non-blocking connect similar to the one in Steven's "Unix Network Programming" on pg 450. I create the socket, set it to non-blocking and call connect which of course returns immediately with a SOCKET_EINPROGRESS error ( as expected ). Then I call socket_select with a timeout greater than 0 and socket_select returns immediately, even though the socket's state is still SOCKET_EINPROGRESS. errno 115: Operation now in progress Reproduce code: --- function ConnectSocket($remote, $port) { $sock = NULL; if (!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) return NULL; socket_set_nonblock($sock); if ([EMAIL PROTECTED]($sock, $remote, $port+0)) { if (socket_select($rin = array($sock), $win = $rin, $ein = NULL, 30.0) < 1) return NULL; if (socket_recv($sock, $buf, 0, 0) === false) { print socket_strerror(socket_last_error()) . "\n"; return NULL; } } socket_set_block($sock); return $sock; } ConnectSocket('206.190.60.37', 80); Expected result: socket_select should block until either the connection completes or the timeout is exceeded. Actual result: -- socket_select returns immediately. SOCKET_EINPROGRESS Operation now in progress -- Edit this bug report at http://bugs.php.net/?id=45514&edit=1
#45514 [NEW]: socket_select + timeout returns immediately on non-blocking connect
From: rbarnes at aethon dot com Operating system: Ubuntu 7.10 / Linux 2.6.22-14 PHP version: 5.2.6 PHP Bug Type: Sockets related Bug description: socket_select + timeout returns immediately on non-blocking connect Description: I'm trying to implement a non-blocking connect similar to the one in Steven's "Unix Network Programming" on pg 450. I create the socket, set it to non-blocking and call connect which of course returns immediately with a SOCKET_EINPROGRESS error ( as expected ). Then I call socket_select with a timeout greater than 0 and socket_select returns immediately, even though the socket's state is still SOCKET_EINPROGRESS. errno 115: Operation now in progress Reproduce code: --- function ConnectSocket($remote, $port) { $sock = NULL; if (!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) return NULL; socket_set_nonblock($sock); if ([EMAIL PROTECTED]($sock, $remote, $port+0)) { if (socket_select($rin = array($sock), $win = $rin, $ein = NULL, 30.0) < 1) return NULL; if (socket_recv($sock, $buf, 0, 0) === false) { print socket_strerror(socket_last_error()) . "\n"; return NULL; } } socket_set_block($sock); return $sock; } ConnectSocket('206.190.60.37', 80); Expected result: socket_select should block until either the connection completes or the timeout is exceeded. Actual result: -- socket_select returns immediately. SOCKET_EINPROGRESS Operation now in progress -- Edit bug report at http://bugs.php.net/?id=45514&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45514&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45514&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45514&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45514&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45514&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45514&r=needtrace Need Reproduce Script:http://bugs.php.net/fix.php?id=45514&r=needscript Try newer version:http://bugs.php.net/fix.php?id=45514&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45514&r=support Expected behavior:http://bugs.php.net/fix.php?id=45514&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45514&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45514&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45514&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45514&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45514&r=dst IIS Stability:http://bugs.php.net/fix.php?id=45514&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45514&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45514&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45514&r=nozend MySQL Configuration Error:http://bugs.php.net/fix.php?id=45514&r=mysqlcfg