为什么select返回-1

「已注销」 「已注销」 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
模仿别人的程序,客户端和服务器通信,但是老是连接上了,信息发送不过去,后来调试的时候是在使用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代表什么出错呢??
请各位帮帮我!
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
「已注销」
进程/线程/DLL 15,466 成员 49,169 内容