Is it possible to specify the outgoing network int

2020-04-08 03:54发布

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条回答
趁早两清
2楼-- · 2020-04-08 04:18

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));
查看更多
登录 后发表回答