起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 1203|回复: 2

Winsock Error Codes

[复制链接]
发表于 2004-6-21 09:49:27 | 显示全部楼层 |阅读模式
Winsock Error Codes

The following list identifies the Winsock error codes. These values are used by the WSAGetLastError function to report and identify errors caused by other Winsock functions.

The following Winsock error codes are listed in ascending numerical order.



WSAEINTR (10004)
Interrupted Function Call -- A blocking operation was cancelled.

WSAEACCESS (10013)
Permission Denied -- An attempt to access a socket was forbidden by its access permissions.
以一种访问权限不允许的方式做了一个访问套接字的尝试。
客户端安装了防火墙,拒绝访问网络端口。

WSAEFAULT (10014)
Bad Address -- An invalid pointer address was specified in a function call.

WSAEINVAL (10022)
Invalid Argument -- An invalid argument was passed to a function.

WSAEMFILE (10024)
Too Many Open Files -- There are too many open sockets.

WSAEWOULDBLOCK (10035)
Resource Temporarily Unavailable -- The specified socket operation cannot be completed immediately, but the operation should be retried later.

WSAEINPROGRESS (10036)
Operation Now in Progress -- A blocking operation is currently executing.

WSAEALREADY (10037)
Operation Already in Progress -- An operation was attempted on a non-binding socket that already had an operation in progress.

WSAENOTSOCK (10038)
Socket Operation on Non-Socket -- An operation was attempted on something that is not a socket.
在一个非套接字上尝试了一个操作

WSAEDESTADDRREQ (10039)
Destination Address Required -- A required address was omitted from a socket operation.

WSAEMSGSIZE (10040)
Message Too Long -- A message was sent on a datagram socket that exceeds the internal message buffer or some other limit.

WSAEPROTOTYPE (10041)
Protocol Wrong Type for Socket -- A protocol was specified that is not supported by the target socket.

WSAENOPROTOOPT (10042)
Bad Protocol Option -- An unknown, invalid, or unsupported protocol option or leel was specified.

WSAEPROTONOSUPPORT (10043)
Protocol Not Supported -- The specified protocol is not supported or is not implemented.

WSAESOCKTNOSUPPORT (10044)
Socket Type Not Supported -- The specified socket type is not supported in the address family.

WSAEOPNOTSUPP (10045)
Operation Not Supported -- The specified operation is not supported by the referenced object.

WSAEPFNOSUPPORT (10046)
Protocol Family Not Supported -- The specified protocol family is not supported or is not implemented.

WSAEAFNOSUPPORT (10047)
Address Family Not Supported by Protocol Family -- An address incompatible with the requested network protocol was used.

WSAEADDRINUSE (10048)
Address Already in Use -- An attempt to use the same IP address and port with two different sockets simultaneously was made.

WSAEADDRNOTAVAIL (10049)
Cannot Assign Requested Address -- The requested address is not valid (given the context of the function).
10049 无法指定所请求的IP地址--在其上下文中,该请求的地址无效。

被请求的地址在它的环境中是不合法的。通常地在bind()函数试图将一个本地机器不合法的地址绑扎到套接字时产生。它也可能在connect()、sendto()、WSAConnect()、WSAJoinLeaf()或WSASendTo()函数调用时因远程机器的远程地址或端口号非法(如0地址或0端口号)而产生。
请检查地址和端口号是正确的(尽量使用IP地址而不是机器名)

WSAENETDOWN (10050)
Network is Down -- A socket operation encountered a network that is down.

WSAENETUNREACH (10051)
Network is Unreachable -- A socket operation encountered an unreachable network.

WSAENETRESET (10052)
Network Dropped Connection on Reset -- A connection was broken due to "keep-alive" activity detecting a failure.

WSAECONNABORTED (10053)
Software Caused Connection Abort -- A connection was aborted by software on the host computer.

WSAECONNRESET (10054)
Connection Reset by Peer -- A connection was forcibly closed by the remote host.

WSAENOBUFS (10055)
No Buffer Space Available -- A socket operation could not be performed because the system ran out of buffer space or the queue was full.
由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作。
1.检查Windows所在磁盘的空间
2.重新启动机器,有可能之前的程序没有正常结束,占用了大量的端口或者内存
3.修改Windows的最大临时端口数量
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\MaxUserPort的值缺省为5000

WSAEISCONN (10056)
Socket is Already Connected -- A connect request was made on a socket that is already connected.

WSAENOTCONN (10057)
Socket is Not Connected -- An attempt to send or receive data failed because the socket is not connected.
由于套接字没有连接并且(当使用一个 sendto 调用发送数据报套接字时)没有提供地址,发送或接收数据的请求没有被接受。
可能是由于网关或者路由器、服务器防火墙封掉了所需的2048端口造成的。

WSAESHUTDOWN (10058)
Cannot Send After Socket Shutdown -- An attempt to send or receive data failed because the socket has already been shut down.

WSAETIMEDOUT (10060)
Connection Timed Out -- The remote host failed to respond within the timeout period.
由于连接方在一段时间后没有正确的答复或连接的主机没有反应,连接尝试失败。
服务器安装了防火墙造成的。

WSAECONNREFUSED (10061)
Connection Refused -- The target machine actively refused the attempt to connect to it.
由于目标机器积极拒绝,无法连接。
一般是因为服务器端没有运行Socket Server造成的。

WSAEHOSTDOWN (10064)
Host is Down -- The destination host is down.

WSAEHOSTUNREACH (10065)
No Route to Host -- The destination host is unreachable.

WSAEPROCLIM (10067)
Too Many Processes -- The Winsock implementation has exceeded the number of applications that can use it simultaneously.

WSASYSNOTREADY (10091)
Network Subsystem is Unavailable -- The underlying system to provide network services is unavailable.

WSAVERNOTSUPPORTED (10092)
winsock.dll Version Out of Range -- The Winsock implementation does not support the requested Winsock version.

WSANOTINITIALIZED (10093)
Successful WSAStartup Not Yet Performed -- The calling application has not successfully called WSAStartup to initiate a Winsock session.

WSAEDISCON (10094)
Graceful Shutdown in Progress -- The remote party has initiated a graceful shutdown sequence.

WSATYPE_NOT_FOUND (10109)
Class Type Not Found -- The specified class was not found.

WSAHOST_NOT_FOUND (11001)
Host Not Found -- No network host matching the hostname or address was found.

WSATRY_AGAIN (11002)
Non-Authoritative Host Not Found -- A temporary error while resolving a hostname occured, and should be retried later.

WSANO_RECOVERY (11003)
This is a Non-Recoverable Error -- Some sort of non-recoverable error occured during a database lookup.

WSANO_DATA (11004)
Valid Name, No Data Record of Requested Type -- The requested name is valid and was found, but does not have the associated data requested.

Constant Definitions

Const WSAEINTR = 10004
Const WSAEACCESS = 10013
Const WSAEFAULT = 10014
Const WSAEINVAL = 10022
Const WSAEMFILE = 10024
Const WSAEWOULDBLOCK = 10035
Const WSAEINPROGRESS = 10036
Const WSAEALREADY = 10037
Const WSAENOTSOCK = 10038
Const WSAEDESTADDRREQ = 10039
Const WSAEMSGSIZE = 10040
Const WSAEPROTOTYPE = 10041
Const WSAENOPROTOOPT = 10042
Const WSAEPROTONOSUPPORT = 10043
Const WSAESOCKTNOSUPPORT = 10044
Const WSAEOPNOTSUPP = 10045
Const WSAEPFNOSUPPORT = 10046
Const WSAEAFNOSUPPORT = 10047
Const WSAEADDRINUSE = 10048
Const WSAEADDRNOTAVAIL = 10049
Const WSAENETDOWN = 10050
Const WSAENETUNREACH = 10051
Const WSAENETRESET = 10052
Const WSAECONNABORTED = 10053
Const WSAECONNRESET = 10054
Const WSAENOBUFS = 10055
Const WSAEISCONN = 10056
Const WSAENOTCONN = 10057
Const WSAESHUTDOWN = 10058
Const WSAETIMEDOUT = 10060
Const WSAECONNREFUSED = 10061
Const WSAEHOSTDOWN = 10064
Const WSAEHOSTUNREACH = 10065
Const WSAEPROCLIM = 10067
Const WSASYSNOTREADY = 10091
Const WSAVERNOTSUPPORTED = 10092
Const WSANOTINITIALIZED = 10093
Const WSAEDISCON = 10094
Const WSATYPE_NOT_FOUND = 10109
Const WSAHOST_NOT_FOUND = 11001
Const WSATRY_AGAIN = 11002
Const WSANO_RECOVERY = 11003
Const WSANO_DATA = 11004
回复

使用道具 举报

发表于 2004-11-9 17:12:40 | 显示全部楼层

如何查看Socket错误的信息

可以在命令模式下输入
C:>net helpmsg 10049
查看错误信息。

此命令的语法是:

NET HELPMSG
message#

NET HELPMSG 用于显示 Windows 网络消息的信息。(诸如错误、警告、警报、消息)。 当用户输入 NET HELPMSG 和一个 4 位数字的 Windows 错误 (例如,NET2182)时,Windows 就会告诉用户关于这个消息的信息,并且为用户提供解决此问题的方法。

message#  是用户需要帮助时所需提供的 4 位数 Windows 消息号。用户不必将 NET 做为消息号的一部分输入。

例如:
C:\>net helpmsg 10049

在其上下文中,该请求的地址无效。


C:\>net helpmsg 10061

由于目标机器积极拒绝,无法连接。


C:\>net helpmsg 10060

由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
回复 支持 反对

使用道具 举报

发表于 2005-10-13 12:12:42 | 显示全部楼层
WSAECONNRESET (10054)
Connection Reset by Peer -- A connection was forcibly closed by the remote host.
远程主机强迫关闭了一个现有的连接。

如果频繁出现这样的情况,通常是因为服务器认为客户端没有响应,主动断开了客户端的连接,解决方法可以是让客户端保持与服务端的连接。
修改客户端的config.xml文件
在<Configure>下面增加
<Connect HoldTime="0"/>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-12-23 05:09 , Processed in 0.036041 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表