NET_DestroyStreamSocket(3)
π NET_DestroyStreamSocket(3) π
okay bestie, we're in the SDL_net3 FUNCTIONS section of the SDL_net manual, and today's main character is NET_DestroyStreamSocket β the lil cleanup queen who takes your stream sockets to their final resting place π«Ά
β¨ NAME β¨
NET_DestroyStreamSocket β dispose of a previously-created stream socket. literally the goodbye button π
πΈ SYNOPSIS πΈ
#include <SDL3_net/SDL_net.h>
void NET_DestroyStreamSocket(NET_StreamSocket *sock); /* Destroy your sockets when finished with them. Does not block, handles shutdown internally. */
yes the comment is in the code block, that's just how they do it here, and it's giving helpful honestly π
π¦ DESCRIPTION π¦
so this will immediately disconnect the other side of the connection, if necessary. like, no waiting around, no "let me think about it", just gone β¨ and fr fr, any further attempts to read or write the socket on the remote end will fail.
now here's the part you need to clock, bestie: this will _abandon_ any data queued for sending that hasn't made it to the socket. not "finish sending it first", not "politely wait" β abandon. π so if you actually need that data to arrive, you should wait for it to transmit before destroying the socket, using NET_GetStreamSocketPendingWrites() or NET_WaitUntilStreamSocketDrained().
and any data that has arrived from the remote end of the connection that hasn't been read yet? lost. gone. poof. π
not me destroying sockets with unread data like it's nothing π check your pending writes FIRST, i'm begging
π FUNCTION PARAMETERS π
sockβ stream socket to destroy. the one we're sending off π
π THREAD SAFETY π
do not operate on the same socket from multiple threads at the same time without supplying a serialization mechanism. that's the rule. that's the vibe check, and you will fail it if you ignore this π«
but β different threads may access different sockets at the same time without problems. so like, everybody gets their own socket, everybody stays in their own lane, no drama π
β AVAILABILITY β
this function is available since SDL_net 3.0.0. iconic behavior, been here since the beginning π
π SEE ALSO π
NET_CreateClient(3)NET_AcceptClient(3)NET_GetStreamSocketPendingWrites(3)NET_WaitUntilStreamSocketDrained(3)
the whole friend group fr fr π«Ά go read them, iykyk
and that's the page!! this is from SDL_net, version SDL_net 3.2.0, and it's filed under NET_DestroyStreamSocket(3). slay, go clean up your sockets responsibly, bestie πβ¨ππ¦πΈ
π¦ where this page comes from
- fedora 43: SDL3_net-devel 3.2.0-2.fc43 Β· Zlib
- fedora 43: SDL3_net-devel 3.2.0-2.fc43 Β· Zlib
- fedora 44: SDL3_net-devel 3.2.0-2.fc44 Β· Zlib
- fedora 44: SDL3_net-devel 3.2.0-2.fc44 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms