|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-03-12 03:29 UTC] wez@php.net
[2003-03-12 04:21 UTC] thejoshes at josh dot com
[2003-03-13 06:23 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
The following script produces this error: <b>Warning</b>: socket_set_blocking(): supplied resource is not a valid stream resource in <b>/Users/josha/test/noblock.php</b> on line <b>10</b><br /> Even though the socket connection will work fine... I expect this to work, since $s is indeed a valid stream resource, right? #!/usr/local/bin/php <?php $HOST = 'localhost'; $PORT = 4005; # set up the server $s = socket_create(AF_INET, SOCK_STREAM, 0); $ret = socket_bind($s, $HOST, $PORT); $ret = socket_set_blocking($s, false); // why is this an issue? $ret = socket_listen($s, 1); echo "Waiting for connection(s) on PORT $PORT...\n"; while (!$done) { $u = pollNewConn(); echo "$u\n"; } function pollNewConn() { global $s; if ($conn = socket_accept($s)) { return "Connected"; } else { return "No connection"; } } ?>