The error code of the last failed socket call on this thread: WSAGetLastError on Windows, errno on Unix.
Read it straight after the call that failed. Compare it with SOCKET_WOULDBLOCK, SOCKET_WOULDBLOCK_CONNECT or the
WSAE... constants.
get_last_socket_error :: () -> W.OS_Error_Code
The error code of the last failed socket call on this thread: WSAGetLastError on Windows, errno on Unix.
Read it straight after the call that failed. Compare it with SOCKET_WOULDBLOCK, SOCKET_WOULDBLOCK_CONNECT or the
WSAE... constants.
Returns
- W.OS_Error_Code
get_last_socket_error :: () -> P.OS_Error_Code
The error code of the last failed socket call on this thread: errno on Unix, WSAGetLastError on Windows.
Read it straight after the call that failed, before any other call can replace it. Compare it with SOCKET_WOULDBLOCK,
SOCKET_WOULDBLOCK_CONNECT or the platform's own error constants.
Returns
- P.OS_Error_Code
assert(socket_init());
// A port that was bound and then released has nobody listening on it.
probe := socket(AF_INET, .SOCK_STREAM, .TCP);
assert(bind(probe, htonl(INADDR_LOOPBACK), 0) == 0);
closed: sockaddr_in;
length: socklen_t = size_of(sockaddr_in);
assert(getsockname(probe, cast(*sockaddr) *closed, *length) == 0);
close_and_reset(*probe);
client := socket(AF_INET, .SOCK_STREAM, .TCP);
defer close_and_reset(*client);
assert(connect(client, cast(*sockaddr) *closed, length) != 0);
assert(get_last_socket_error() != 0);Doesn't run in the browser (skipped on wasm).