对于在基于 UNIX 的环境中的 TCP/IP 用户,下表列出了某些最常见的错误原因码 (errno)。它不是完整的错误列表。可以在文件 /usr/include/sys/errno.h 中找到 Errno。针对每一种操作系统给出了errno 号码。
基于 UNIX 的 TCP/IP errno
Errno
Errno号码
AIXHP-UXSolarisUnixWareLinux
说明
EINTR
4
4
4
4
4
系统调用中断。
EAGAIN
11
11
11
11
11
资源临时不可用。
EBUSY
16
16
16
16
16
资源正忙。
EMFILE
24
24
24
24
24
每个进程文件描述符表已满。
EPIPE
32
32
32
32
32
管道断开。
EADDRINUSE
67
226
125
125
98
已经在使用指定的地址。
ENETDOWN
69
228
127
127
100
网络已停止。
ENETUNREACH
70
229
128
128
101
没有到达网络的可用路由。
ENETRESET
71
230
129
129
102
重设时网络已卸下了连接。
ECONNRESET
73
232
131
131
104
伙伴已重设了连接。
ENOBUFS
74
233
132
132
105
系统中没有足够的缓冲区空间资源可用来完成调用。
ENOTCONN
76
235
134
134
107
未连接套接字。
ETIMEDOUT
78
238
145
145
110
连接超时。
ECONNREFUSED
79
239
146
146
111
连接已被拒绝。若您正在尝试与数据库相连,则检查是否已成功启动了服务器上的数据库管理程序和 TCP/IP 协议支持。 若使用 SOCKS 协议支持,则还要确保在 SOCKS 服务器上已成功启动了 TCP/IP 协议支持。
EHOSTDOWN
80
241
147
147
147
主机已停机。
EHOSTUNREACH
81
242
148
148
113
没有到达主机的可用路由。
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
对 于 OS/2 环境中的 TCP/IP 用户,下面的列表显示了最常见的 errno。它不是完整的错误列表。可以在文件 nerrno.h 中找到 Errno。此文件是 TCP/IP 产品包含文件的一部分。若尚未安装这些文件,则在您的系统上可能不会出现。errno 号码本身是用括号括起来的。
SOCEINTR (10003):系统调用被中断。
SOCEMFILE (10024):打开的文件太多。
SOCEPIPE (10032):管道被断开。
EADDRINUSE (10048):已经在使用指定的地址。
ENETDOWN (10050):网络已停止。
ENETUNREACH (10051):没有到达网络的可用路由。
ENETRESET (10052):重设时网络已卸下了连接。
SOCECONNABORTED (10053):软件导致连接异常中止。
ECONNRESET (10054):伙伴已重设了连接。
ENOBUFS (10055):无缓冲区空间可用。
ENOTCONN (10057):未连接套接字。
ETIMEDOUT (10060): 在进行连接之前,建立连接超时。
ECONNREFUSED (10061):连接已被拒绝。若您正在尝试与数据库相连,则检查是否已成功启动了服务器上的数据库管理程序和 TCP/IP 协议支持。
若使用 SOCKS 协议支持,则还要确保在 SOCKS 服务器上已成功启动了 TCP/IP 协议支持。
EHOSTDOWN (10064):主机已停机。
EHOSTUNREACH (10065):没有到达主机的可用路由。
SOCEOS2ERR (10100):OS/2 错误。
有关 OS/2 TCP/IP 通信错误的详情,参考 OS/2 TCP/IP 文档。
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
对 于 Windows 95、Windows 98 或 Windows NT 下的 TCP/IP 或 IPX/SPX 用户,下面的列表显示了最常见的错误码。它不是完整的错误列表。可以在文件 winsock.h 中找到由 WSAGetLastError() 返回的错误。
WSAEINVAL (10022):若在函数 WSASTARTUP 上接收到此错误,则此 DLL 不支持应用程序所支持的 Windows Sockets 版本。
WSAEMFILE (10024):没有可用的文件描述符。
WSAEWOULDBLOCK (10035):套接字标记为未分块,而操作将分块。
WSAEINPROGRESS (10036):正在进行分块 Windows Sockets 操作。
WSAENOPROTOOPT (10042):该选项是未知的或不受支持的。
WSAEADDRINUSE (10048):已经在使用指定的地址。
WSAENETDOWN (10050):网络子系统已失败。
WSAENETUNREACH (10051):此时不能从此主机到达网络。
WSAENETRESET (10052):由于重设了远程主机,所以连接已断开。
WSAECONNABORTED (10053):由于超时或其他故障,导致虚拟电路异常中止。重设时网络已卸下了连接。
WSAECONNRESET (10054):伙伴已重设了连接。
WSAENOBUFS (10055):无缓冲区空间可用,连接太多。
WSAENOTCONN (10057):未连接套接字。
WSAETIMEDOUT (10060):在进行连接之前,建立连接超时。
WSAECONNREFUSED (10061):连接已被拒绝。若您正在尝试与数据库相连,则检查在服务器上是否已成功启动了数据库管理程序和 TCP/IP 协议支持。
WSAEHOSTUNREACH (10065):此时不能从此主机到达网络。
WSASYSNOTREADY (10091):基础网络子系统未准备好进行网络通信。
WSAVERNOTSUPPORTED (10092):此特定的 Windows Sockets 实现未提供请求的 Windows Sockets API 支持的版本。
WSAHOST_NOT_FOUND (11001):找不到主机。
WSATRY_AGAIN (11002):找不到主机。请求从名称服务器中检索主机名的 IP 地址失败。
WSANO_DATA (11004):名称无效,没有请求的类型的数据记录。名称服务器或 hosts 文件不识别主机名,或者在 services 文件中未指定服务名。
有关 Windows 下的 TCP/IP 通信错误的详情,参考 Windows Sockets 文档。
而我们可以通过以下代码来查看errno错误:
#include
printf ("errno is: %d\n", errno);
strerror(errno):获取errno对应的错误
/****************************获取错误代码描述**************/
#include
/*****************************************************************/
errno.00 is: Successerrno.01 is: Operation not permittederrno.02 is: No such file or directoryerrno.03 is: No such processerrno.04 is: Interrupted system callerrno.05 is: Input/output errorerrno.06 is: No such device or addresserrno.07 is: Argument list too longerrno.08 is: Exec format errorerrno.09 is: Bad file descriptorerrno.10 is: No child processeserrno.11 is: Resource temporarily unavailable[资源临时不可用](连续发送数据时候回出此错,加延时)errno.12 is: Cannot allocate memoryerrno.13 is: Permission deniederrno.14 is: Bad addresserrno.15 is: Block device requirederrno.16 is: Device or resource busyerrno.17 is: File existserrno.18 is: Invalid cross-device linkerrno.19 is: No such deviceerrno.20 is: Not a directoryerrno.21 is: Is a directoryerrno.22 is: Invalid argumenterrno.23 is: Too many open files in systemerrno.24 is: Too many open fileserrno.25 is: Inappropriate ioctl for deviceerrno.26 is: Text file busyerrno.27 is: File too largeerrno.28 is: No space left on deviceerrno.29 is: Illegal seekerrno.30 is: Read-only file systemerrno.31 is: Too many linkserrno.32 is: Broken pipe[断开的管道](原因:the broken pipe error occurs if one end of theTCP socket closes connection(using disconnect) or gets killed and the otherend tries to still write to it. An indication of a closed/terminatedconnection is a return value of 0 when you try to read from that socketusing recv. After receiving such an error, if you try to still write to thesocket, your process gets sent the SIGPIPE signal which kills it. )errno.33 is: Numerical argument out of domainerrno.34 is: Numerical result out of rangeerrno.35 is: Resource deadlock avoidederrno.36 is: File name too longerrno.37 is: No locks availableerrno.38 is: Function not implementederrno.39 is: Directory not emptyerrno.40 is: Too many levels of symbolic linkserrno.41 is: Unknown error 41errno.42 is: No message of desired typeerrno.43 is: Identifier removederrno.44 is: Channel number out of rangeerrno.45 is: Level 2 not synchronizederrno.46 is: Level 3 haltederrno.47 is: Level 3 reseterrno.48 is: Link number out of rangeerrno.49 is: Protocol driver not attachederrno.50 is: No CSI structure availableerrno.51 is: Level 2 haltederrno.52 is: Invalid exchangeerrno.53 is: Invalid request descriptorerrno.54 is: Exchange fullerrno.55 is: No anodeerrno.56 is: Invalid request codeerrno.57 is: Invalid sloterrno.58 is: Unknown error 58errno.59 is: Bad font file formaterrno.60 is: Device not a streamerrno.61 is: No data availableerrno.62 is: Timer expirederrno.63 is: Out of streams resourceserrno.64 is: Machine is not on the networkerrno.65 is: Package not installederrno.66 is: Object is remoteerrno.67 is: Link has been severederrno.68 is: Advertise errorerrno.69 is: Srmount errorerrno.70 is: Communication error on senderrno.71 is: Protocol errorerrno.72 is: Multihop attemptederrno.73 is: RFS specific errorerrno.74 is: Bad messageerrno.75 is: Value too large for defined data typeerrno.76 is: Name not unique on networkerrno.77 is: File descriptor in bad stateerrno.78 is: Remote address changederrno.79 is: Can not access a needed shared libraryerrno.80 is: Accessing a corrupted shared libraryerrno.81 is: .lib section in a.out corruptederrno.82 is: Attempting to link in too many shared librarieserrno.83 is: Cannot exec a shared library directlyerrno.84 is: Invalid or incomplete multibyte or wide charactererrno.85 is: Interrupted system call should be restartederrno.86 is: Streams pipe errorerrno.87 is: Too many userserrno.88 is: Socket operation on non-socketerrno.89 is: Destination address requirederrno.90 is: Message too longerrno.91 is: Protocol wrong type for socketerrno.92 is: Protocol not availableerrno.93 is: Protocol not supportederrno.94 is: Socket type not supportederrno.95 is: Operation not supportederrno.96 is: Protocol family not supportederrno.97 is: Address family not supported by protocolerrno.98 is: Address already in useerrno.99 is: Cannot assign requested addresserrno.100 is: Network is downerrno.101 is: Network is unreachableerrno.102 is: Network dropped connection on reseterrno.103 is: Software caused connection aborterrno.104 is: Connection reset by peer[l连接被对端重置]errno.105 is: No buffer space availableerrno.106 is: Transport endpoint is already connectederrno.107 is: Transport endpoint is not connectederrno.108 is: Cannot send after transport endpoint shutdownerrno.109 is: Too many references: cannot spliceerrno.110 is: Connection timed outerrno.111 is: Connection refusederrno.112 is: Host is downerrno.113 is: No route to hosterrno.114 is: Operation already in progresserrno.115 is: Operation now in progresserrno.116 is: Stale NFS file handleerrno.117 is: Structure needs cleaningerrno.118 is: Not a XENIX named type fileerrno.119 is: No XENIX semaphores availableerrno.120 is: Is a named type fileerrno.121 is: Remote I/O errorerrno.122 is: Disk quota exceedederrno.123 is: No medium founderrno.124 is: Wrong medium typeerrno.125 is: Operation cancelederrno.126 is: Required key not availableerrno.127 is: Key has expirederrno.128 is: Key has been revokederrno.129 is: Key was rejected by serviceerrno.130 is: Owner diederrno.131 is: State not recoverableerrno.132 is: Unknown error 132132-255 全是Unknown error