錯誤號 |
錯誤 |
可能的原因 |
EAGAIN |
Try again |
在讀數據的時候,沒有數據在底層緩衝的時候會遇到,一般的處理是循環進行讀操作,異步模式還會等待讀事件的發生再讀 |
EWOULDBLOCK |
Operation would block |
在我們的環境中和EAGAIN是一個值, 一般情況下只關心EAGAIN就可以了 |
EPIPE |
Broken pipe |
接收端關閉(緩衝中沒有多餘的數據),但是發送端還在write. |
ECONNRESET |
Connection reset by peer |
收 到RST包 可能是 接收到數據後不進行讀取或者沒有讀取完畢直接close,另一端再調用write或者read操作,這個時候需要檢查一下是否存在髒數據或者一端某些情況 下斷開的情況. 另外 使用了SO_LINGER後close連接,另一端也會收到這個錯誤. 另外在epoll中一般也是可能返回EPOLLHUP事件。 連接的時候也可能出現這樣的錯誤,這個參考後面的 "listen的時候的backlog有什麼影響 "中的說明 |
EINTR |
Interrupted system call |
被其他的系統調用中斷了, 對於句柄進行操作比較容易出現,一般裸用recv都是需要判斷的, 處理也很簡單, 再進行一次操作就可以了 |
ETIMEDOUT |
Connection timed out |
連接超時, 但是在我們ul_sread_xxx或者ul_swrite_xx系列中也被我們用來表示讀寫超時 |
ECONNREFUSED |
Connection refused |
拒絕連接, 一般在機器存在但是相應的端口上沒有數據的時候出現 |
ENETUNREACH |
Network is unreachable |
網絡不可達,可能是由於路器的限制不能訪問,需要檢查網絡 |
EADDRNOTAVAIL |
Cannot assign requested address |
不能分配本地地址,一般在端口不夠用的時候會出現,很可能是短連接的TIME_WAIT問題造成 |
EADDRINUSE |
Address already in use |
地址已經被使用, 已經有相應的服務程序佔用了這個端口, 或者佔用端口的程序退出了但沒有設置端口複用 |
ENOTCONN |
Transport endpoint is not connected |
連接沒有鏈上。 在一個socket出來還沒有accept或者connenct, 還有一種情況就是收到對方發送過來的RST包,系統已經確認連接被斷 |
對一些常見錯誤號的分析
Linux Socket Errno錯誤代碼列表
124EMEDIUMTYPE Wrong medium type
123 ENOMEDIUM No medium found
122EDQUOT Disk quota exceeded
121 EREMOTEIO Remote I/O error
120EISNAM Is a named type file
119ENAVAIL No XENIX semaphores available
118ENOTNAM Not a XENIX named type file
117EUCLEAN Structure needs cleaning
116ESTALE Stale NFS file handle
115 EINPROGRESS +Operation nowin progress
114EALREADY Operation already in progress
113 EHOSTUNREACH No route tohost
112 EHOSTDOWN Host is down
111 ECONNREFUSED Connection refused
110 ETIMEDOUT +Connection timed out
109 ETOOMANYREFS Too manyreferences: cannot splice
108 ESHUTDOWN Cannot send after transport endpoint shutdown
107ENOTCONN Transport endpoint is not connected
106EISCONN Transport endpoint is alreadyconnected
105ENOBUFS No buffer space available
104 ECONNRESET Connection reset by peer
103 ECONNABORTED Softwarecaused connection abort
102 ENETRESET Network dropped connection on reset
101 ENETUNREACH Networkis unreachable
100ENETDOWN Network is down
99 EADDRNOTAVAIL Cannot assignrequested address
98 EADDRINUSE Address already in use
97 EAFNOSUPPORT Addressfamily not supported by protocol
96 EPFNOSUPPORT Protocolfamily not supported
95 EOPNOTSUPP Operation not supported
94 ESOCKTNOSUPPORT Socket typenot supported
93 EPROTONOSUPPORT Protocol notsupported
92 ENOPROTOOPT Protocol not available
91 EPROTOTYPE Protocol wrong type for socket
90EMSGSIZE +Message too long
89 EDESTADDRREQ Destination address required
88ENOTSOCK Socket operation on non-socket
87EUSERS Too many users
86ESTRPIPE Streams pipe error
85 ERESTART Interrupted system call should be restarted
84EILSEQ Invalid or incompletemultibyte or wide character
83ELIBEXEC Cannot exec a shared library directly
82ELIBMAX Attempting to link in too manyshared libraries
81 ELIBSCN .lib section in a.out corrupted
80ELIBBAD Accessing a corrupted shared library
79ELIBACC Can not access a needed sharedlibrary
78EREMCHG Remote address changed
77EBADFD File descriptor in bad state
76ENOTUNIQ Name not unique on network
75EOVERFLOW Value too large for defined data type
74EBADMSG +Bad message
73EDOTDOT RFS specific error
72EMULTIHOP Multihop attempted
71EPROTO Protocol error
70ECOMM Communication error onsend
69ESRMNT Srmount error
68EADV Advertise error
67ENOLINK Link has been severed
66EREMOTE Object is remote
65ENOPKG Package not installed
64ENONET Machine is not on the network
63ENOSR Out of streams resources
62ETIME Timer expired
61ENODATA No data available
60ENOSTR Device not a stream
59EBFONT Bad font file format
57EBADSLT Invalid slot
56EBADRQC Invalid request code
55ENOANO No anode
54EXFULL Exchange full
53EBADR Invalid request descriptor
52EBADE Invalid exchange
51EL2HLT Level 2 halted
50ENOCSI No CSI structure available
49EUNATCH Protocol driver not attached
48ELNRNG Link number out of range
47EL3RST Level 3 reset
46EL3HLT Level 3 halted
45EL2NSYNC Level 2 not synchronized
44ECHRNG Channel number out of range
43EIDRM Identifier removed
42ENOMSG No message of desired type
40ELOOP Too many levels ofsymbolic links
39 ENOTEMPTY +Directory not empty
38 ENOSYS +Function not implemented
37ENOLCK +No locks available
36 ENAMETOOLONG +File name toolong
35EDEADLK +Resource deadlock avoided
34ERANGE +Numerical result out of range
33EDOM +Numerical argument out ofdomain
32EPIPE +Broken pipe
31EMLINK +Too many links
30EROFS +Read-only file system
29ESPIPE +Illegal seek
28ENOSPC +No space left on device
27EFBIG +File too large
26ETXTBSY Text file busy
25ENOTTY +Inappropriate ioctl for device
24EMFILE +Too many open files
23ENFILE +Too many open files in system
22EINVAL +Invalid argument
21EISDIR +Is a directory
20ENOTDIR +Not a directory
19ENODEV +No such device
18EXDEV +Invalid cross-device link
17EEXIST +File exists
16EBUSY +Device or resource busy
15ENOTBLK Block device required
14 EFAULT +Bad address
13EACCES +Permission denied
12ENOMEM +Cannot allocate memory
11EAGAIN +Resource temporarily unavailable
10ECHILD +No child processes
9EBADF +Bad file descriptor
8ENOEXEC +Exec format error
7E2BIG +Argument list too long
6ENXIO +No such device or address
5EIO +Input/output error
4EINTR +Interrupted system call
3ESRCH +No such process
2ENOENT +No such file or directory
1EPERM +Operation not permitted
# 0-- Success