为什么select返回-1
「已注销」 2009-03-07 10:21:19 模仿别人的程序,客户端和服务器通信,但是老是连接上了,信息发送不过去,后来调试的时候是在使用select()的时候它返回了-1,直接跳出了程序,没有发送数据,代码为:
BOOL CDealCMDThread::SOKCET_Select(SOCKET hSocket,int nTimeOut,BOOL bWrite)
{
fd_set fdset;
struct timeval tv;
FD_ZERO(&fdset);
FD_SET(hSocket, &fdset);
tv.tv_sec = nTimeOut;
tv.tv_usec = 0;
int nRes = 0;
if(bWrite)
nRes = select(hSocket + 1, NULL , &fdset, NULL, &tv);
else
nRes = select(hSocket + 1, &fdset, NULL , NULL, &tv);
if(nRes == 0)
{
// DW(_T("SOKCET_Select Time Out"));
return FALSE;
}
if(nRes < 0)
{
int nErr = WSAGetLastError();
// DW(_T("SOKCET_Select Select Error = %d"),nErr);
return FALSE;
}
if(FD_ISSET(hSocket, &fdset))
return TRUE;
return FALSE;
}
为什么nRes的返回值为-1啊,返回-1代表什么出错呢??
请各位帮帮我!