|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-08-07 20:43 UTC] alex at cedevices dot com
Description: ------------ Standard latest xampp setup (including PHP 5.0.4). When using socket_create_listen(port), it does not listen on all interfaces as the docs indicate that it would. I was unable to connect to the machine using anything other than localhost (127.0.0.1). The workaround is to use socket_create, socket_bind (with 0.0.0.0 as the address) and socket_listen to accomplish the same task. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 03:00:01 2025 UTC |
Same issue. Small test script: =================================================== <?php $server = socket_create_listen(5900); if (!$server){ throw new Exception('Cannot create socket'); } $client = socket_accept($server); if (!$client){ throw new Exception('Client connect failed.'); } while ($client){ $data = socket_read($client, 1024); if ($data != ""){ $data = trim($data); socket_write($client, 'You said: '.$data."\r\n"); if ($data=='bye'){ socket_close($client); socket_close($server); $client=null; } } else { socket_close($client); socket_close($server); $client=null; } } =================================================== Environment =================================================== Windows 7 64-bit D:\php-trunk>php -v PHP 5.3.99-dev (cli) (built: May 15 2011 09:31:01) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2011 Zend Technologies (also fails in 5.3.6 release) After running the script above: =================================================== C:\Users\Keith>netstat -nap tcp Active Connections Proto Local Address Foreign Address State [..snip..] TCP 127.0.0.1:5900 0.0.0.0:0 LISTENING C:\Users\Keith>nc -v 127.0.0.1 5900 sleek [127.0.0.1] 5900 (?) open Testing You said: Testing 123 You said: 123 bye You said: bye C:\Users\Keith>nc -v 192.168.0.6 5900 sleek [192.168.0.6] 5900 (?): connection refused