I have some functions that use stream_socket_client (not curl) in php and I have multiple eth1 eth2 ...etc interfaces with different ips So i want to use different interfaces when i connect as a client, can I do that? I can't find no option for that nor in php.ini
Here is how to add IP interface in stream_socket_client
// 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);
http://pt.php.net/manual/en/context.socket.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With