|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-03-09 17:31 UTC] sean at caedmon dot net
socket_get_status is supposed to return an associative array, it _always_ returns null for me. No array, no object, no string print_r(socket_get_status($verifiedSocketResource)) prints nothing. I've tried this on two separate 4.1.x installs. The php4win version (4.1.1) and the Debian Unstable version (4.1.2 -- CGI). PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 23 17:00:02 2025 UTC |
CVS Date: 2002.03.18 (afternoon EST) ---- socket_get_status has a return value now, but it still is incorrect. I'm wary of posting code here, because I don't want to present the image of asking for support, but in fact, socket_get_status is not returning a proper value. socket_get_status now complains about invalid file-handle resource (when the passed resource is a socket resource -- I haven't tried this with an actual file resource (although, that would seem useless)). Attached is the code I used to determine this. S --- //sock2.php ob_implicit_flush(); $ip = "localhost"; $port = "10000"; $listenSock = socket_create(AF_INET, SOCK_STREAM, 0); socket_set_nonblock($listenSock); socket_bind($listenSock, $ip, $port); socket_listen($listenSock, 0); $connected = false; while (!$connected) { $msgSock = @socket_accept($listenSock); $connected = is_resource($msgSock); } echo "connected...\n"; socket_set_nonblock($msgSock); for($i=1; $i<=300; $i++) { // ~5 minutes socket_write($msgSock, ".", 1); // send "."; echo "."; $status = socket_get_status($listenSock); print_r($status); sleep(1); } /* note: to get the code to break out of the while loop, connect to localhost on port 10000 (nc[or telnet] localhost 10000) in another terminal. */ --- Here is my terminal log (terminal of the executing sock2.php): --- sean@adnagaporp:~/php-dev/php4$ ./php -q ~/httpd/site/dev/sockets/sock2.php connected... .<br /> <b>Warning</b>: socket_get_status(): supplied resource is not a valid File-Handle resource in <b>/home/sean/httpd/site/dev/sockets/sock2.php</b> on line <b>26</b><br /> .<br /> <b>Warning</b>: socket_get_status(): supplied resource is not a valid File-Handle resource in <b>/home/sean/httpd/site/dev/sockets/sock2.php</b> on line <b>26</b><br /> .<br /> (etc...) --- END