您的位置:首页 > 理论基础 > 计算机网络

关于TCP Socket 非阻塞模式时客户端connect返回SOCKET_ERROR的情况

2010-12-13 10:18 656 查看
一般有三种情况:

1,服务端不存在;

2,连接不存在;

3,通过WSAGetLastError获取到错误。

以下是MSDN的解释。

WSAEWOULDBLOCK

(10035)

Resource temporarily unavailable.
This error is returned from operations on nonblocking sockets that cannot be
completed immediately, for example recv
when no data is queued to be read from the socket. It is a nonfatal error, and
the operation should be retried later. It is normal for WSAEWOULDBLOCK to be
reported as the result from calling
connect on a nonblocking SOCK_STREAM socket,
since some time must elapse for the connection to be established.
即在非阻塞模式时,connect不会马上返回,它需要时间来确定。因此他会返回这个值.此时它是正常的.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐