服务器为新浪云,本机为Windows,开启ss代理。
$service_port = getservbyname('http', 'tcp');
$address = gethostbyname('server address');
if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
}
if (socket_bind($sock, $address, $service_port) === false) {
echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
}
if (socket_listen($sock) === false) {
echo "socket_listen() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
}
执行报错:
Warning: socket_bind(): unable to bind address [10049]: The requested address is not valid in its context.
Warning: socket_listen(): unable to listen on socket [10022]: An invalid argument was supplied.
怀疑是本机不能与服务器进行直连
stackoverflow参考
请问v友们是如何解决这些问题的?端口转发?
还有服务器与客户端有没有更简单和方便的通信方式?Http?
1
cover 2015-04-28 17:36:14 +08:00
怀疑本机不能与服务直连。。 直接telnet下看端口通不通就好了吧
|
3
402645707 2015-04-28 17:46:47 +08:00 via Android
没事干开ss干嘛
|
5
nicksite 2015-04-28 17:54:58 +08:00
sae 的socket bind/listen方法无法使用。http://sae.sina.com.cn/doc/python/socket.html
|