socket:connectが接続するIP /ポートを検索するのにかかる許容timeOut時間を短縮したいですか?IP 10.0.0.xを使用するNetgearのような一部のネットワークルーターでは、タイムアウトするのに1秒もかかりません。
注:「選択」は後で行われます
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
}
どうも