Go to the documentation of this file.
21 #include "../../string_func.h"
24 #include "../../safeguards.h"
41 return this->
error == WSAEWOULDBLOCK;
45 return this->
error == EWOULDBLOCK || this->
error == EAGAIN;
56 return this->
error == WSAECONNRESET;
58 return this->
error == ECONNRESET;
69 return this->
error == WSAEWOULDBLOCK;
71 return this->
error == EINPROGRESS;
84 if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, this->
error,
85 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer,
sizeof(buffer), NULL) == 0) {
95 static std::mutex mutex;
96 std::lock_guard<std::mutex> guard(mutex);
109 return this->
error != 0;
120 #elif defined(__OS2__)
136 u_long nonblocking = 1;
137 return ioctlsocket(d, FIONBIO, &nonblocking) == 0;
138 #elif defined __EMSCRIPTEN__
142 return ioctl(d, FIONBIO, &nonblocking) == 0;
153 #ifdef __EMSCRIPTEN__
158 return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (
const char *)&flags,
sizeof(flags)) == 0;
170 socklen_t len =
sizeof(err);
171 getsockopt(d, SOL_SOCKET, SO_ERROR, (
char *)&err, &len);
bool HasError() const
Check whether an error was actually set.
std::string message
The string representation of the error (set on first call to AsString).
bool WouldBlock() const
Check whether this error describes that the operation would block.
static NetworkError GetLast()
Get the last network error.
NetworkError GetSocketError(SOCKET d)
Get the error from a socket, if any.
int error
The underlying error number from errno or WSAGetLastError.
bool IsConnectInProgress() const
Check whether this error describes a connect is in progress.
bool IsConnectionReset() const
Check whether this error describes a connection reset.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Abstraction of a network error where all implementation details of the error codes are encapsulated i...
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
bool SetNonBlocking(SOCKET d)
Try to set the socket into non-blocking mode.
NetworkError(int error)
Construct the network error with the given error code.
#define lastof(x)
Get the last element of an fixed size array.
bool SetNoDelay(SOCKET d)
Try to set the socket to not delay sending.
const char * AsString() const
Get the string representation of the error message.