sdlNetGetStreamSocketPendingWrites function

int sdlNetGetStreamSocketPendingWrites(
  1. Pointer<SdlNetStreamSocket> sock
)

Query bytes still pending transmission on a stream socket.

If SDLNet_WriteToStreamSocket() couldn't send all its data immediately, it will queue it to be sent later. This function lets the app see how much of that queue is still pending to be sent.

The library will try to send more queued data before reporting what's left, but it will not block to do so.

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 SDL_DestroyStreamSocket().

\param sock the stream socket to query. \returns number of bytes still pending transmission, -1 on failure; call SDL_GetError() for details.

\threadsafety You should not operate on the same socket from multiple threads at the same time without supplying a serialization mechanism. However, different threads may access different sockets at the same time without problems.

\since This function is available since SDL_Net 3.0.0.

\sa SDLNet_WriteToStreamSocket \sa SDLNet_WaitUntilStreamSocketDrained

extern SDL_DECLSPEC int SDLCALL SDLNet_GetStreamSocketPendingWrites(SDLNet_StreamSocket *sock)

Implementation

int sdlNetGetStreamSocketPendingWrites(Pointer<SdlNetStreamSocket> sock) {
  final sdlNetGetStreamSocketPendingWritesLookupFunction =
      libSdl3Net.lookupFunction<
              Int32 Function(Pointer<SdlNetStreamSocket> sock),
              int Function(Pointer<SdlNetStreamSocket> sock)>(
          'SDLNet_GetStreamSocketPendingWrites');
  return sdlNetGetStreamSocketPendingWritesLookupFunction(sock);
}