关于socket的connect超时的问题
摘要:
timeval tm; fd_set set; unsigned long ul = 1; ioctlsocket(sock, FIONBIO, &ul); //设置为非阻塞模式 bool ret = false; if (connect(...) == -1) { tm.tv_set = TIME_OUT_TIME; tm.tv_uset = 0; FD_ZERO(&set); FD_SET(sock, &set); if (select(sock, NULL, &set, NULL, &tm) > 0) { getsockopt(sockfd, 阅读全文
posted @ 2011-01-25 10:34 hgy413 阅读(647) 评论(0) 推荐(0) 编辑