NET_WAITUNTILSTREAMSOCKETDRAINED(3)
β¨ NET_WaitUntilStreamSocketDrained β¨
okay bestie, this is a page from the SDL_net3 function crew, and it's about the moment you just gotta wait for your socket to finish yapping. π
πΈ NAME πΈ
NET_WaitUntilStreamSocketDrained β block until all of a stream socket's pending data is sent.
like, sit there and chill until the socket is done sending everything. no cap. π¦
π SYNOPSIS π
#include <SDL3_net/SDL_net.h>
int NET_WaitUntilStreamSocketDrained(NET_StreamSocket *sock, Sint32 timeout);
π DESCRIPTION π
so here's the tea: if NET_WriteToStreamSocket() couldn't send all its data immediately, it will queue it up to be sent later. this function is literally just letting your app sleep π΄ until all that data is transmitted. it's giving "let her cook."
it takes a timeout value, and that's in milliseconds, bestie β how long to wait for transmission to complete:
- a timeout of
-1tells the library to wait indefinitely (iconic, patient queen behavior π) - a timeout of
0just checks the current status and returns immediately β and that's functionally equivalent to callingNET_GetStreamSocketPendingWritesπ«Ά
if you don't want your program to block (main character doesn't wait in lines β), you can call NET_GetStreamSocketPendingWrites from time to time until you get a result <= 0.
and now the serious part, don't skip this π¨: if the connection has failed β remote side dropped us, or one of a million other networking failures occurred β this function will report failure by returning -1. stream sockets only report failure for unrecoverable conditions. once a stream socket fails, you should assume it is no longer usable and should destroy it with NET_DestroyStreamSocket(). it's over, it's done, she's not coming back. π
π FUNCTION PARAMETERS π
sockβ the stream socket to wait on. your girl. the one you're waiting for. π§timeoutβ number of milliseconds to wait for draining to complete.-1to wait indefinitely,0to check once without waiting.
β RETURN VALUE β
returns the number of bytes still pending transmission, or -1 on failure β and if it fails, call SDL_GetError() for the details, because she will tell you exactly what went wrong. π
π₯ THREAD SAFETY π₯
okay so, do not operate on the same socket from multiple threads at the same time without supplying a serialization mechanism. that's a vibe check you will fail. π
however, different threads may access different sockets at the same time without problems. so everyone can have their own socket, just no sharing, periodt. β¨
π¦ AVAILABILITY π¦
this function is available since SDL_net 3.0.0. she's not new new, she's established. πΈ
π SEE ALSO π
and that's the whole page, bestie π₯° this lil slice of SDL_net is from SDL_net 3.2.0 β go drain that socket, you absolute icon. bye bye πππ«Ά
π¦ 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