|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-11-01 00:26 UTC] naox at o2 dot pl
Description: ------------ PHP really needs interface binding for fsockopen() (like socket_bind()) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 16:00:01 2025 UTC |
is this some thing what you are looking for ? $fp = fsockopen("tcp://127.0.0.1", 8080); or $fp = fsockopen("unix:///tmp/mysocket", ..);stream_socket_client already exists for this purpose: <?php function test($a) { $s = stream_socket_client( "tcp://nebm.geleia.net:80", $errno, $errstr, 1, STREAM_CLIENT_CONNECT, stream_context_create(array( 'socket' => array('bindto' => "[$a]:1224") )) ); fwrite($s, "GET /whoami HTTP/1.0\r\n\r\n"); while ($f = fgets($s)) { $line = $f; } echo $line, "\n"; } test('2001:470:1f08:d77::2'); test('2001:470:94a2:1::1'); 2001:470:1f08:d77::2 2001:470:94a2:1::1 One could also more simply have used file_get_contents with the http wrapper in this situation.