`
garman
  • 浏览: 28930 次
  • 来自: ...
文章分类
社区版块
存档分类
最新评论

socket error 错误码

阅读更多
 

1.1         WINDOWS平台SOCKET错误码说明<o:p></o:p>

MSDN对于SOCKET异常ID的描述<o:p></o:p>

错误码值<o:p></o:p>

错误码标识<o:p></o:p>

含义<o:p></o:p>

10004<o:p></o:p>

WSAEINTR<o:p></o:p>

Interrupted function call. <o:p></o:p>

A blocking operation was interrupted by a call to WSACancelBlockingCall.<o:p></o:p>

10013<o:p></o:p>

WSAEACCES<o:p></o:p>

Permission denied. <o:p></o:p>

An attempt was made to access a socket in a way forbidden by its access permissions. An example is using a broadcast address for sendto without broadcast permission being set using setsockopt(SO_BROADCAST). <o:p></o:p>

10014<o:p></o:p>

WSAEFAULT<o:p></o:p>

Bad address. <o:p></o:p>

The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument which is a struct sockaddr is smaller than sizeof(struct sockaddr). <o:p></o:p>

10022<o:p></o:p>

WSAEINVAL<o:p></o:p>

Invalid argument. <o:p></o:p>

Some invalid argument was supplied (for example, specifying an invalid level to the setsockopt function). In some instances, it also refers to the current state of the socket - for instance, calling accept on a socket that is not listening. <o:p></o:p>

10024<o:p></o:p>

WSAEMFILE<o:p></o:p>

Too many open files. <o:p></o:p>

Too many open sockets. Each implementation may have a maximum number of socket handles available, either globally, per process or per thread. <o:p></o:p>

10035<o:p></o:p>

WSAEWOULDBLOCK<o:p></o:p>

Resource temporarily unavailable. <o:p></o:p>

This error is returned from operations on non-blocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket. It is a non-fatal error, and the operation should be retried later. It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a non-blocking SOCK_STREAM socket, since some time must elapse for the connection to be established.<o:p></o:p>

10036<o:p></o:p>

WSAEINPROGRESS<o:p></o:p>

Operation now in progress. <o:p></o:p>

A blocking operation is currently executing. Windows Sockets only allows a single blocking operation to be outstanding per task (or thread), and if any other function call is made (whether or not it references that or any other socket) the function fails with the WSAEINPROGRESS error. <o:p></o:p>

10037<o:p></o:p>

WSAEALREADY<o:p></o:p>

Operation already in progress. <o:p></o:p>

An operation was attempted on a non-blocking socket that already had an operation in progress - i.e. calling connect a second time on a non-blocking socket that is already connecting, or canceling an asynchronous request (WSAAsyncGetXbyY) that has already been canceled or completed.<o:p></o:p>

10038<o:p></o:p>

WSAENOTSOCK<o:p></o:p>

Socket operation on non-socket. <o:p></o:p>

An operation was attempted on something that is not a socket. Either the socket handle parameter did not reference a valid socket, or for select, a member of an fd_set was not valid. <o:p></o:p>

10039<o:p></o:p>

WSAEDESTADDRREQ<o:p></o:p>

Destination address required. <o:p></o:p>

A required address was omitted from an operation on a socket. For example, this error will be returned if sendto is called with the remote address of ADDR_ANY. <o:p></o:p>

10040<o:p></o:p>

WSAEMSGSIZE<o:p></o:p>

Message too long. <o:p></o:p>

A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself. <o:p></o:p>

10041<o:p></o:p>

WSAEPROTOTYPE<o:p></o:p>

Protocol wrong type for socket. <o:p></o:p>

A protocol was specified in the socket function call that does not support the semantics of the socket type requested. For example, the ARPA Internet UDP protocol cannot be specified with a socket type of SOCK_STREAM. <o:p></o:p>

10042<o:p></o:p>

WSAENOPROTOOPT<o:p></o:p>

Bad protocol option. <o:p></o:p>

An unknown, invalid or unsupported option or level was specified in a getsockopt or setsockopt call.<o:p></o:p>

10043<o:p></o:p>

WSAEPROTONOSUPPORT<o:p></o:p>

Protocol not supported. <o:p></o:p>

The requested protocol has not been configured into the system, or no implementation for it exists. For example, a socket call requests a SOCK_DGRAM socket, but specifies a stream protocol. <o:p></o:p>

10044<o:p></o:p>

WSAESOCKTNOSUPPORT<o:p></o:p>

Socket type not supported. <o:p></o:p>

The support for the specified socket type does not exist in this address family. For example, the optional type SOCK_RAW might be selected in a socket call, and the implementation does not support SOCK_RAW sockets at all. <o:p></o:p>

10045<o:p></o:p>

WSAEOPNOTSUPP<o:p></o:p>

Operation not supported. <o:p></o:p>

The attempted operation is not supported for the type of object referenced. Usually this occurs when a socket descriptor to a socket that cannot support this operation, for example, trying to accept a connection on a datagram socket.<o:p></o:p>

10046<o:p></o:p>

WSAEPFNOSUPPORT<o:p></o:p>

Protocol family not supported. <o:p></o:p>

The protocol family has not been configured into the system or no implementation for it exists. Has a slightly different meaning to WSAEAFNOSUPPORT, but is interchangeable in most cases, and all Windows Sockets functions that return one of these specify WSAEAFNOSUPPORT. <o:p></o:p>

10047<o:p></o:p>

WSAEAFNOSUPPORT<o:p></o:p>

Address family not supported by protocol family. <o:p></o:p>

An address incompatible with the requested protocol was used. All sockets are created with an associated "address family" (i.e. AF_INET for Internet Protocols) and a generic protocol type (i.e. SOCK_STREAM). This error will be returned if an incorrect protocol is explicitly requested in the socket call, or if an address of the wrong family is used for a socket, e.g. in sendto. <o:p></o:p>

10048<o:p></o:p>

WSAEADDRINUSE<o:p></o:p>

Address already in use. <o:p></o:p>

Only one usage of each socket address (protocol/IP address/port) is normally permitted. This error occurs if an application attempts to bind a socket to an IP address/port that has already been used for an existing socket, or a socket that wasn't closed properly, or one that is still in the process of closing. For server applications that need to bind multiple sockets to the same port number, consider using setsockopt(SO_REUSEADDR). Client applications usually need not call bind at all - connect will choose an unused port automatically. When bind is called with a wild-card address (involving ADDR_ANY), a WSAEADDRINUSE error could be delayed until the specific address is "committed." This could happen with a call to other function later, including connect, listen, WSAConnect or WSAJoinLeaf.<o:p></o:p>

10049<o:p></o:p>

WSAEADDRNOTAVAIL<o:p></o:p>

Cannot assign requested address. <o:p></o:p>

The requested address is not valid in its context. Normally results from an attempt to bind to an address that is not valid for the local machine. This can also result from connect, sendto, WSAConnect, WSAJoinLeaf, or WSASendTo when the remote address or port is not valid for a remote machine (e.g. address or port 0). <o:p></o:p>

<o:p> </o:p>

10050<o:p></o:p>

WSAENETDOWN<o:p></o:p>

Network is down. <o:p></o:p>

A socket operation encountered a dead network. This could indicate a serious failure of the network system (i.e. the protocol stack that the WinSock DLL runs over), the network interface, or the local network itself. <o:p></o:p>

10051<o:p></o:p>

WSAENETUNREACH<o:p></o:p>

Network is unreachable. <o:p></o:p>

A socket operation was attempted to an unreachable network. This usually means the local software knows no route to reach the remote host.<o:p></o:p>

10052<o:p></o:p>

WSAENETRESET<o:p></o:p>

Network dropped connection on reset. <o:p></o:p>

The connection has been broken due to "keep-alive" activity detecting a failure while the operation was in progress. It can also be returned by setsockopt if an attempt is made to set SO_KEEPALIVE on a connection that has already failed. <o:p></o:p>

10053<o:p></o:p>

WSAECONNABORTED<o:p></o:p>

Software caused connection abort. <o:p></o:p>

An established connection was aborted by the software in your host machine, possibly due to a data transmission timeout or protocol error. <o:p></o:p>

10054<o:p></o:p>

WSAECONNRESET<o:p></o:p>

Connection reset by peer. <o:p></o:p>

A existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, or the remote host used a "hard close" (see setsockopt for more information on the SO_LINGER option on the remote socket.) This error may also result if a connection was broken due to "keep-alive" activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.<o:p></o:p>

10055<o:p></o:p>

WSAENOBUFS<o:p></o:p>

No buffer space available. <o:p></o:p>

An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. <o:p></o:p>

<o:p> </o:p>

10056<o:p></o:p>

WSAEISCONN<o:p></o:p>

Socket is already connected. <o:p></o:p>

A connect request was made on an already connected socket. Some implementations also return this error if sendto is called on a connected SOCK_DGRAM socket (For SOCK_STREAM sockets, the to parameter in sendto is ignored), although other implementations treat this as a legal occurrence. <o:p></o:p>

10057<o:p></o:p>

WSAENOTCONN<o:p></o:p>

Socket is not connected. <o:p></o:p>

A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using sendto) no address was supplied. Any other type of operation might also return this error - for example, setsoc

分享到:
评论

相关推荐

    socket错误代码对应表

    在Windows系统中,可以通过命令提示符下的`net helpmsg [错误代码]`来获取特定错误码的详细解释。例如,如果想查询错误代码10060的信息,只需在命令行中输入`net helpmsg 10060`即可。 #### 二、常见错误代码详解 ...

    windows socket错误码及出错原因

    这些错误码可以分为四个部分,即 Windows Sockets 实现返回的错误码、Berkeley Sockets 定义的错误码、Windows Sockets 扩充的错误码和 getXbyY() 函数返回的错误码。 了解 Windows Socket 错误码非常重要,因为...

    SocketError

    这些错误代码不仅包括 Windows Sockets 实现中特有的错误,还包含了传统的 Berkeley Sockets 定义的错误码,以确保程序的可移植性和兼容性。 下面将详细介绍一些常见的 SocketError 错误代码及其含义。 #### ...

    VC套接字socket示例(带接收出错SOCKET_ERROR重启机制)

    它的返回值表示接收到的字节数,如果返回`SOCKET_ERROR`,则表明发生了错误。 当`recvfrom()`返回`SOCKET_ERROR`时,我们的重启机制将发挥作用。错误处理通常包括使用`WSAGetLastError()`获取错误代码,然后根据...

    套接字错误码1

    7. Socket error 10035 - 资源暂时不可用:该错误码表示套接字操作所需的资源暂时不可用。 8. Socket error 10036 - 操作现在进行中:该错误码表示套接字操作现在正在进行中。 9. Socket error 10037 - 操作已经在...

    Can't create TCP/IP socket(24).原因及解决办法

    4. "Can't create TCP-IP socket (10106)_端口绑定失败=端口冲突.url":虽然10106不是我们讨论的24,但这个错误码表明端口绑定失败,可能是由于端口已经被其他进程占用,也可能是另一个相关的问题。 5. "Linux errno...

    总结:Linux中socket常见错误分析

    2. ECONNREFUSED:当远程服务器对SYN数据段发送RST数据段时,表示在指定端口没有服务进程等待连接,此时connect函数立即返回错误。 3. EHOSTUNREACH或ENETUNREACH:如果路由中产生了“目的地不可到达”的ICMP错误,...

    联通sgip协议错误码描述

    当 SP 调用深讯 API 时,也可能出现一些错误码,例如 ERROR_SOCKET_CREATE、ERROR_CONNECT、ERROR_SOCKET_WRITE 等,这些错误码都是由于网络连接或数据传输过程中出现的错误所致。 sgip 协议的错误码描述是非常...

    VC++ DLL for Socket

    9. **SocketError.h**:错误处理头文件,包含了Socket通信过程中可能出现的错误码和对应的处理机制。 在实际的开发过程中,开发者需要在`Communicate.cpp`中实现Socket的初始化、连接、监听、发送和接收等功能,并...

    Linux下Socket编程的端口问题 ( Bind(): Address already in use ) PDF版

    当尝试绑定一个已经被其他进程使用的端口时,`bind()`函数会返回一个错误码“EADDRINUSE”,即地址已经被使用。这种情况常常出现在以下几种情况: 1. **进程未完全终止**:虽然通过`Ctrl + C`强制结束了进程,但该...

    VC_socket编程入门实例

    在实际项目中,可能还需要处理异常情况,比如超时、错误码等。同时,为了提高程序的健壮性和可读性,通常会将这些功能封装成类或者函数。通过不断实践和学习,你将能更好地理解和掌握VC_socket编程,构建出强大的...

    用php的socket跟flash的socket通信

    - 如果创建失败,该函数返回一个资源标识符,可以通过 `socket_strerror` 函数来获取错误信息。 - **绑定 Socket**: - `socket_bind` 函数用于将 socket 绑定到特定地址和端口。如果绑定失败,则同样通过 `...

    用php实现socket

    可以使用`socket_last_error()`和`socket_strerror()`检查错误码和获取错误信息,或者使用`set_error_handler()`自定义错误处理函数。 5. **示例代码** 创建一个简单的PHP Socket Server: ```php $serverSocket...

    HTML5调用Socket接口例子

    socket.onerror = function(error) { console.error('An error occurred:', error); }; ``` 在提供的压缩包文件中,我们看到有`OursNET.HTML5.WebSocket.sln`和`oursnet.net.sln`两个解决方案文件,它们可能是包含...

    tcl socket 编程实例

    - 如果连接超时,则返回错误;否则返回Socket通道。 #### 四、TCL Socket 实际应用案例 下面是一个更具体的案例,展示了如何实现简单的客户端-服务器通信。 **Server端代码** ```tcl proc accept {chan addr ...

    windows下设置socket的connect超时

    而非阻塞模式下,即使操作未能立即完成,线程也不会被阻塞,而是立即返回一个错误码或特定值。 3. **Connect函数**:用于建立客户端与服务器之间的连接。在客户端程序中,connect函数会尝试与指定的服务器地址建立...

    Socket编程的发送接收消息函数

    recv会等待发送缓冲中的数据被协议完全发送,如果在此期间出现网络错误,recv会返回`SOCKET_ERROR`。当发送缓冲为空或数据发送完毕,recv会检查接收缓冲区。如果缓冲区无数据或协议正在接收,recv会阻塞等待。一旦...

    Socket Send and Receive

    如果失败,则返回`SOCKET_ERROR`。 - **注意事项**: - 发送数据时,`len`参数应该准确地指定需要发送的数据量。 - 如果发送的数据量大于TCP/IP协议栈允许的最大值(通常是64KB),则需要分多次发送。 - 如果...

    vs2010实现socket客户端代码示例

    为了便于调试和测试,你可能还需要添加错误处理代码,例如检查`WSAGetLastError()`返回的错误码。 本示例虽然简单,但对于初学者来说是一个很好的起点,能够理解Socket编程的基本流程。随着对Socket编程的深入学习...

Global site tag (gtag.js) - Google Analytics