NET_GETSTREAMSOCKETPENDINGWRITES(3)
π NET_GetStreamSocketPendingWrites(3) π
okay bestie, welcome to the SDL_net3 FUNCTIONS section of the manual, and today's main character is NET_GetStreamSocketPendingWrites. she's a little query function and she's lowkey essential. let's get into it π«Ά
β¨ NAME β¨
NET_GetStreamSocketPendingWrites β ask a stream socket how many bytes are still sitting in the queue waiting to be sent. it's giving "are we there yet" but for your network buffer π
πΈ SYNOPSIS πΈ
#include <SDL3_net/SDL_net.h>
int NET_GetStreamSocketPendingWrites(NET_StreamSocket *sock);
π¦ DESCRIPTION π¦
so here's the tea π β if NET_WriteToStreamSocket() couldn't send all of its data right that second, it doesn't just give up, no ma'am. it queues the leftovers to be sent later. this function is how your app peeks at that queue and goes "okay so how much of this is still pending?"
the library will try to send more of the queued data before it reports back what's left β she's helpful like that β but she will not block to do it. no hanging, no waiting around, she's busy π
now for the serious part, bestie, pay attention π if the connection has failed β like the remote side dropped us, or one of a million other networking failures happened β this function reports failure by returning -1. stream sockets only report failure for unrecoverable conditions. and once a stream socket fails? assume it's done, she's not coming back, and you should destroy it with NET_DestroyStreamSocket(). periodt.
π FUNCTION PARAMETERS π
sockβ the stream socket you wanna query, bestie. the one you're checking up on π
β RETURN VALUE β
returns the number of bytes still pending transmission, or -1 on failure. and if you get that -1? call SDL_GetError() for the details, she'll tell you what went wrong π
π₯ THREAD SAFETY π₯
okay so do not operate on the same socket from multiple threads at the same time unless you've got yourself a serialization mechanism, bestie. that's a vibe check you will fail π
but good news β different threads can absolutely access different sockets at the same time with zero problems. parallel slay π
π AVAILABILITY π
this function has been available since SDL_net 3.0.0. she's an OG π
π SEE ALSO π
go read those too, they're part of the same friend group π
and that's the whole page, bestie!! this was SDL_net version 3.2.0, signing off with so much love β stay drained, stay non-blocking, and never forget to destroy your failed sockets π«Άβ¨π
π¦ 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