對於在基於 UNIX 的環境中的 TCP/IP 用戶,下表列出了某些最常見的錯誤原因碼 (errno)。它不是完整的錯誤列表。可以在文件 /usr/include/sys/errno.h 中找到 Errno。針對每一種操作系統給出了errno 號碼。
Errno |
|
說明 |
---|
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 <errno.h> printf ("errno is: %d\n", errno);
strerror(errno):獲取errno對應的錯誤
/****************************獲取錯誤代碼描述**************/
#include <string.h> /* for strerror */
#include <errno.h>
#include <stdio.h>
int main(int argc, char ** argv) {
int i = 0;
for(i = 0; i < 256; i++)
printf("errno.%02d is: %s/n", i, strerror(i));
return 0;
}
/*****************************************************************/
errno.00 is: Success
errno.01 is: Operation not permitted
errno.02 is: No such file or directory
errno.03 is: No such process
errno.04 is: Interrupted system call
errno.05 is: Input/output error
errno.06 is: No such device or address
errno.07 is: Argument list too long
errno.08 is: Exec format error
errno.09 is: Bad file descriptor
errno.10 is: No child processes
errno.11 is: Resource temporarily unavailable[資源臨時不可用](連續發送數據時候回出此錯,加延時)
errno.12 is: Cannot allocate memory
errno.13 is: Permission denied
errno.14 is: Bad address
errno.15 is: Block device required
errno.16 is: Device or resource busy
errno.17 is: File exists
errno.18 is: Invalid cross-device link
errno.19 is: No such device
errno.20 is: Not a directory
errno.21 is: Is a directory
errno.22 is: Invalid argument
errno.23 is: Too many open files in system
errno.24 is: Too many open files
errno.25 is: Inappropriate ioctl for device
errno.26 is: Text file busy
errno.27 is: File too large
errno.28 is: No space left on device
errno.29 is: Illegal seek
errno.30 is: Read-only file system
errno.31 is: Too many links
errno.32 is: Broken pipe[斷開的管道](原因:the broken pipe error occurs if one end of the
TCP socket closes connection(using disconnect) or gets killed and the other
end tries to still write to it. An indication of a closed/terminated
connection is a return value of 0 when you try to read from that socket
using recv. After receiving such an error, if you try to still write to the
socket, your process gets sent the SIGPIPE signal which kills it.
)
errno.33 is: Numerical argument out of domain
errno.34 is: Numerical result out of range
errno.35 is: Resource deadlock avoided
errno.36 is: File name too long
errno.37 is: No locks available
errno.38 is: Function not implemented
errno.39 is: Directory not empty
errno.40 is: Too many levels of symbolic links
errno.41 is: Unknown error 41
errno.42 is: No message of desired type
errno.43 is: Identifier removed
errno.44 is: Channel number out of range
errno.45 is: Level 2 not synchronized
errno.46 is: Level 3 halted
errno.47 is: Level 3 reset
errno.48 is: Link number out of range
errno.49 is: Protocol driver not attached
errno.50 is: No CSI structure available
errno.51 is: Level 2 halted
errno.52 is: Invalid exchange
errno.53 is: Invalid request descriptor
errno.54 is: Exchange full
errno.55 is: No anode
errno.56 is: Invalid request code
errno.57 is: Invalid slot
errno.58 is: Unknown error 58
errno.59 is: Bad font file format
errno.60 is: Device not a stream
errno.61 is: No data available
errno.62 is: Timer expired
errno.63 is: Out of streams resources
errno.64 is: Machine is not on the network
errno.65 is: Package not installed
errno.66 is: Object is remote
errno.67 is: Link has been severed
errno.68 is: Advertise error
errno.69 is: Srmount error
errno.70 is: Communication error on send
errno.71 is: Protocol error
errno.72 is: Multihop attempted
errno.73 is: RFS specific error
errno.74 is: Bad message
errno.75 is: Value too large for defined data type
errno.76 is: Name not unique on network
errno.77 is: File descriptor in bad state
errno.78 is: Remote address changed
errno.79 is: Can not access a needed shared library
errno.80 is: Accessing a corrupted shared library
errno.81 is: .lib section in a.out corrupted
errno.82 is: Attempting to link in too many shared libraries
errno.83 is: Cannot exec a shared library directly
errno.84 is: Invalid or incomplete multibyte or wide character
errno.85 is: Interrupted system call should be restarted
errno.86 is: Streams pipe error
errno.87 is: Too many users
errno.88 is: Socket operation on non-socket
errno.89 is: Destination address required
errno.90 is: Message too long
errno.91 is: Protocol wrong type for socket
errno.92 is: Protocol not available
errno.93 is: Protocol not supported
errno.94 is: Socket type not supported
errno.95 is: Operation not supported
errno.96 is: Protocol family not supported
errno.97 is: Address family not supported by protocol
errno.98 is: Address already in use
errno.99 is: Cannot assign requested address
errno.100 is: Network is down
errno.101 is: Network is unreachable
errno.102 is: Network dropped connection on reset
errno.103 is: Software caused connection abort
errno.104 is: Connection reset by peer[l連接被對端重置]
errno.105 is: No buffer space available
errno.106 is: Transport endpoint is already connected
errno.107 is: Transport endpoint is not connected
errno.108 is: Cannot send after transport endpoint shutdown
errno.109 is: Too many references: cannot splice
errno.110 is: Connection timed out
errno.111 is: Connection refused
errno.112 is: Host is down
errno.113 is: No route to host
errno.114 is: Operation already in progress
errno.115 is: Operation now in progress
errno.116 is: Stale NFS file handle
errno.117 is: Structure needs cleaning
errno.118 is: Not a XENIX named type file
errno.119 is: No XENIX semaphores available
errno.120 is: Is a named type file
errno.121 is: Remote I/O error
errno.122 is: Disk quota exceeded
errno.123 is: No medium found
errno.124 is: Wrong medium type
errno.125 is: Operation canceled
errno.126 is: Required key not available
errno.127 is: Key has expired
errno.128 is: Key has been revoked
errno.129 is: Key was rejected by service
errno.130 is: Owner died
errno.131 is: State not recoverable
errno.132 is: Unknown error 132
132-255 全是Unknown error