我想减少 socket:connect 查找要连接的 IP/端口所需的允许超时时间?在某些使用 IP 10.0.0.x 的网络路由器(如 Netgear)上,超时只需不到一秒。
注意:“选择”稍后出现
host = gethostbyname("xxx");//invalid IP,
memcpy(&(sin.sin_addr), host->h_addr, host->h_length);
sin.sin_family = host->h_addrtype;
sin.sin_port = htons(4000);
s = socket(AF_INET, SOCK_STREAM, 0);
hConnect = connect(s, (struct sockaddr*)&sin, sizeof(sin));//sits here for 2 minutes before moving on to the next line of code
bConn = 0;// no connect
if (hConnect == 0) {
bConn = 1;// connect made
}
谢谢