69,371
社区成员
发帖
与我相关
我的任务
分享
while(){
select()
sleep()
}
TIMEVAL oWaitTime
oWaitTime.tv_sec = 10*1000; //等待10秒
oWaitTime.tv_usec = 0;
fdSck.fd_count = 1;
fdSck.fd_array[0] = sck; //你的socket
iResult = select(0, &fdSck, NULL, NULL, &oWaitTime); //测试可读
if(iResult < 0)
{
//连接出错
}
else if(iResult == 0)
{
//等待超时
}
else
{
//iResult为收到的字节数
}