COROIO: coroio/accept_errors.hpp Source File
COROIO
Loading...
Searching...
No Matches
accept_errors.hpp
1#pragma once
2
3#include <cerrno>
4
5#ifdef _WIN32
6#include <winsock2.h>
7#endif
8
9namespace NNet {
10
12inline bool IsTransientAcceptError(int err) {
13#ifdef _WIN32
14 return err == WSAEWOULDBLOCK || err == WSAEINTR || err == WSAECONNRESET;
15#else
16 switch (err) {
17 case EAGAIN:
18#if EWOULDBLOCK != EAGAIN
19 case EWOULDBLOCK:
20#endif
21 case EINTR:
22 case ECONNABORTED:
23 case EPROTO:
24#ifdef __linux__
25 // Network errors pending on the new connection, see accept(2). EOPNOTSUPP and
26 // ENOPROTOOPT are left out: they also come from a socket that cannot accept, e.g.
27 // UDP, on every call.
28 case ENETDOWN: case EHOSTDOWN: case ENONET: case EHOSTUNREACH: case ENETUNREACH:
29#endif
30 return true;
31 default:
32 return false;
33 }
34#endif
35}
36
37} // namespace NNet