Closes the socket s points to and sets it to INVALID_SOCKET.
A handle that is already INVALID_SOCKET is left alone, so it is safe to call twice. A failing close is logged through
context.logger but the handle is reset anyway.
close_and_reset :: (s: *Socket, loc := #caller_location)
Closes the socket s points to and sets it to INVALID_SOCKET.
A handle that is already INVALID_SOCKET is left alone, so it is safe to call twice. A failing close is logged through
context.logger but the handle is reset anyway.
Parameters
- s: *Socket
- loc := #caller_location
close_and_reset :: (s: *Socket, loc := #caller_location)
Closes the socket s points to and sets it to INVALID_SOCKET.
A handle that is already INVALID_SOCKET is left alone, so it is safe to call twice and to put in a defer after the
handle may have been closed elsewhere. A failing close is logged through context.logger but the handle is reset
anyway. Data still queued for sending is delivered in the background where the system allows it; call shutdown first to
signal the end of a stream to the peer in order.
Parameters
- s: *Socket
- loc := #caller_location
assert(socket_init());
s := socket(AF_INET, .SOCK_STREAM, .TCP);
assert(s != INVALID_SOCKET);
close_and_reset(*s);
assert(s == INVALID_SOCKET);
close_and_reset(*s);Doesn't run in the browser (skipped on wasm).