MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / netErrorString

Function netErrorString

source/core/StarNetImpl.hpp:45–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#endif
44
45inline String netErrorString() {
46#ifdef STAR_SYSTEM_WINDOWS
47 LPWSTR lpMsgBuf = NULL;
48 int error = WSAGetLastError();
49
50 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
51 | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
52 NULL,
53 error,
54 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
55 (LPTSTR)&lpMsgBuf,
56 0,
57 NULL);
58
59 String result = strf("{} - {}", error, utf16ToString(lpMsgBuf));
60
61 if (lpMsgBuf != NULL)
62 LocalFree(lpMsgBuf);
63
64 return result;
65#else
66 return strf("{} - {}", errno, strerror(errno));
67#endif
68}
69
70inline bool netErrorConnectionReset() {
71#ifdef STAR_SYSTEM_FAMILY_WINDOWS

Callers 13

setMethod · 0.85
receiveMethod · 0.85
sendMethod · 0.85
pollMethod · 0.85
bindMethod · 0.85
listenMethod · 0.85
setNonBlockingMethod · 0.85
SocketMethod · 0.85
setSockOptMethod · 0.85
acceptMethod · 0.85
receiveMethod · 0.85
sendMethod · 0.85

Calls 2

strfFunction · 0.85
utf16ToStringFunction · 0.85

Tested by

no test coverage detected