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

一般有三种情况:

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不会马上返回,它需要时间来确定。因此他会返回这个值.此时它是正常的.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值