Par*_*oft 3 php ip parameters bind interface
我有一些函数在php中使用stream_socket_client(而不是curl)我有多个eth1 eth2 ...等接口与不同的ips所以我想在我作为客户端连接时使用不同的接口,我可以这样做吗?我在php.ini中找不到任何选项
以下是如何在stream_socket_client中添加IP接口
// connect to the internet using the '192.168.0.100' IP
$opts = array(
'socket' => array(
'bindto' => '192.168.0.100:0',
),
);
// create the context...
$context = stream_context_create($opts);
$fp = @stream_socket_client ( $link, $errno, $errstr, 120, STREAM_CLIENT_CONNECT, $context);
Run Code Online (Sandbox Code Playgroud)
http://pt.php.net/manual/en/context.socket.php