服务器为新浪云,本机为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?
