Under Linux, accept () passes the network error that has been waited to the newly established connection, and treats it as an error returned by the Accept (). This is different from the other BSD implementations. In order to run reliably, some network errors defined by the protocol should be detected after accept (), and these errors should be treated as eagain and retry. For the TCP/IP protocol, there are major errors: Enetdown,eproto,enoprotoopt,ehostdown,enonet,ehostunreach,eopnotsupp and Enetunreach.
Eagain or Ewouldblock
The socket is non-blocking and no current connection exists to return Eagain or Ewouldblock. POSIX.1-2001 allows the return value to be any of these two, and does not require a value of two constants to be the same, so that when the application is ported, there is better compatibility.
EBADF
This descriptor is not valid.
econnaborted
The connection has been terminated.
Efault
The addr parameter is not a writable part of the user's address space.
Eintr
The system call is interrupted until a valid connection arrives. For more information, refer to signal (7).
EINVAL
The socket is not listening for connections, or the address length is invalid (for example, is negative).
EINVAL
(Accept4 ()) The value of the flag is not valid.
Emfile
The process for each open file descriptor has reached its limit.
Enfile
The total number of open files has reached the limit of the system.
Enobufs, Enomem
There is not enough memory available. This often means that memory allocations are limited by the range of socket buffers, not system memory.
Enotsock
Reference a file descriptor, not a socket.
Eopnotsupp
The referenced type is not a sock_stream socket.
Eproto
protocol error.
Additionally, the Linux accept () may fail if:
Eperm
The firewall prohibits connections.
Additionally, new network errors that are defined by the new version of the socket may be returned. Different Linux kernels can return other errors, such as Enosr,esocktnosupport,eprotonosupport,etimedout. Erestartsys can also be seen during the tracing process.
About the error handling of Linux Accpet ()