关于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不会马上返回,它需要时间来确定。因此他会返回这个值.此时它是正常的.
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不会马上返回,它需要时间来确定。因此他会返回这个值.此时它是正常的.
相关文章推荐
- connect()返回SOCKET_ERROR不一定就是连接失败
- TCP socket的accept/connect成功返回可是对端却不辞而别
- TCP socket的accept/connect成功返回可是对端却不辞而别
- TCP socket的accept/connect成功返回可是对端却不辞而别
- WinSocket套接字关于Connect函数通过GetLastError 返回10038或者(在一个非套接字上尝试了一个操作)
- 关于socket阻塞与非阻塞情况下的recv、send、read、write返回值
- 关于socket阻塞与非阻塞情况下的recv、send、read、write返回值. +accept,connect
- 基于tcp或者UDP socket 情况下服务器客户端并发操作
- 关于socket应用:一个不断监听一个进程的服务器以及发送信息的客户端 TCP的三次握手和四次挥手
- 关于ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib的解决方案之一
- 一个关于socket在非阻塞模式下connect是否成功的例子
- 客户端-服务器架构、Socket、TCP/UDP简介
- linux 客户端 Socket 非阻塞connect编程(正文)
- 解决“ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (60)”
- linux 客户端 Socket 非阻塞connect编程
- C# 异步TCP Socket聊天室(1服务器,N客户端)
- 关于sqlServer [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket 的解决方法
- 关于 Fatal NI connect error 12170
- C# Socket TCP简单例子(服务器与客户端通信)
- C++ 简单的 Tcp 实现[socket] 服务器端与客户端通信