使用fsockopen指定源IP [英] Specify source ip using fsockopen
本文介绍了使用fsockopen指定源IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在具有多个IP路由到它的服务器上,我想使用PHP的fsockopen从非主接口ip(或可比较的方法,以便能够从另一个ip进行fread和fwrite)打开
On a server with multiple IPs routed to it, I'd like to use PHP's fsockopen to open from a non-primary-interface ip (or a comparable method to be able to make fread and fwrites from a different ip)
推荐答案
对于fsockopen
,这是不可能的.您必须使用套接字包装器:
This is not possible with fsockopen
. You have to use the sockets wrapper:
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($sock, '192.168.1.100');
socket_connect($sock, 'stackoverflow.com', 80);
这篇关于使用fsockopen指定源IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文