NET_GetStreamSocketAddress(3)

πŸ“¦
version 3.2.0 Β· 2 versions
, in fedora 43, fedora 44

πŸ’– NET_GetStreamSocketAddress πŸ’–

okay bestie, this one lives in the SDL_net3 FUNCTIONS section of the manual, and it's genuinely one of the handiest little guys in the whole networking toolbox 🫢


✨ NAME ✨

NET_GetStreamSocketAddress β€” get the remote address of a stream socket. yes, the remote one, the other side of the call, the person on the phone πŸ“žβœ¨


🌸 SYNOPSIS 🌸

#include <SDL3_net/SDL_net.h>

NET_Address * NET_GetStreamSocketAddress(NET_StreamSocket *sock);

πŸ¦‹ DESCRIPTION πŸ¦‹

So like. This function reports the address of the remote side of a stream socket. And here's the tea: that remote side might still be pending connection. Not fully connected yet, still getting ready, still doing its little warm-up stretch 🧚 β€” and this function will still tell you what address it's headed for.

πŸ’€ IMPORTANT BESTIE: this adds a reference to the address. That means the caller _must_ call NET_UnrefAddress() when done with it. Not "should", not "maybe", must. You took a reference, you give it back. No cap. πŸ™ˆ

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • sock β€” the stream socket to query. that's the one you're asking about πŸ‘‘

⭐ RETURN VALUE ⭐

Returns the socket's remote address, or NULL on error β€” and if you get NULL, call SDL_GetError() for the details, because it will absolutely tell you what went wrong πŸ”


🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. every thread. all of them. go wild, main character energy, no locks needed πŸ’…βœ¨


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL_net 3.0.0. so if you're on something older… girl. upgrade. πŸ“


and that's the whole page, mwah πŸ’– thanks for reading, you're doing amazing sweetie, now go unref that address 🫢

β€” with love from the SDL_net 3.2.0 era βœ¨πŸŽ€πŸ¦‹ (that's the source + version stamped on this page, and if you were wondering about a date, bestie, the footer didn't give us one β€” just the version and that gorgeous SDL_net name πŸ’œ)

πŸ“¦ where this page comes from