struct timeval tv = {timeout, 0};
27 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(struct timeval));
28 //setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval));//设置接收超时,不能对connect起作用。
struct timeval tv = {timeout, 0};
27 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(struct timeval));
28 //setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval));//设置接收超时,不能对connect起作用。
转载于:https://www.cnblogs.com/OSLover/p/3603613.html