问题
I need to bind a SoapClient to a specific outbound network interface, but I cannot find any documentation on this. Is this even possible? If not, what are some possible workarounds?
回答1:
You can pass a stream context to your soapclient constructor that has a bindto options set:
$opts = array(
'socket' => array(
'bindto' => '192.168.0.100:0',
),
);
$ctx = stream_context_create($opts);
$client = new SoapClient('the.wsdl', array('stream_context' => $ctx));
来源:https://stackoverflow.com/questions/3444359/is-it-possible-to-specify-the-outgoing-network-interface-to-use-for-a-php-soapcl