NET_GetAddressBytes(3)
π NET_GetAddressBytes(3) π
okay bestie, welcome to the SDL_net3 functions corner of the universe, this one's literally called NET_GetAddressBytes and it does exactly what it says on the tin: it gets you the protocol-level bytes of a network address from a resolved address. iykyk π¦
β¨ NAME β¨
NET_GetAddressBytes β get the protocol-level bytes of a network address from a resolved address π
πΈ SYNOPSIS πΈ
#include <SDL3_net/SDL_net.h>
const void * NET_GetAddressBytes(NET_Address *address, int *num_bytes);
π DESCRIPTION π
okay so first thing, no cap: this data is not human-readable, it's protocol-specific, and it might not even be in a specific byte order. it's giving raw gremlin bytes π
what is it even good for?? honestly, it's only useful for possibly hashing β like to map an address to a specific player in a game β or possibly for handing to a system-level networking API. and btw, that second one is not recommended; an app does this at their own risk. you've been warned, bestie π
π¨ do NOT store these bytes for future runs of the program. there is no promise the format won't change. periodt.
on return, *num_bytes will hold the number of bytes provided with the address. and since the data is not NULL-terminated, this is literally the only way to determine its size β as such, this parameter must not be NULL π
also do not free or modify the returned data, okay?? it belongs to the NET_Address that was queried, and it's valid as long as the object lives. so either make sure the address has a reference for as long as you need this, or make a copy of the bytes. your call, bestie π«Ά
this will return NULL if resolution is still in progress, or if resolution failed. you can use NET_GetAddressStatus() or NET_WaitUntilResolved() to make sure resolution has successfully completed before calling this. vibe check first, then call β¨
and fyi, a human-readable version is available in NET_GetAddressString(), and it isn't any less efficient to query than the raw bytes. so likeβ¦ if you just want to read it, go there π
π¦ FUNCTION PARAMETERS π¦
addressβ theNET_Addressto query. the main character of this whole operation πnum_bytesβ on return, will be set to the number of bytes returned. she's reporting back π
π RETURN VALUE π
returns a pointer to bytes, or NULL on error. and if you get that NULL, call SDL_GetError() for details, she'll tell you what went wrong π
π THREAD SAFETY π
it is safe to call this function from any thread. go off, multithreaded queen π
β AVAILABILITY β
this function is available since SDL_net 3.0.0. vintage but iconic π
π₯ SEE ALSO π₯
and that's the whole page, bestie!! this lil slice of wisdom comes to you from SDL_net, version SDL_net 3.2.0 π«Ά go forth and hash responsibly, mwah πβ¨
π¦ 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