Get the protocol-level bytes of a network address from a resolved address.
Defined in <SDL3_net/SDL_net.h>
const void * NET_GetAddressBytes(NET_Address *address, int *num_bytes);| NET_Address * | address | The NET_Address to query. |
| int * | num_bytes | on return, will be set to the number of bytes returned. |
(const void *) Returns a pointer to bytes, or NULL on error; call SDL_GetError() for details.
This data is not human-readable, is protocol-specific, and might not even be in a specific byte order.
This is only useful for possibly hashing, to map a address to a specific player in a game, or possibly for handing to a system-level networking API (which is not recommended; an app does this at their own risk).
Do not store these bytes for future runs of the program; there is no promise the format won't change.
On return *num_bytes will hold the number of bytes provided with the address. Since the data is not NULL-terminated, this is the only way to determine its size; as such, this parameter must not be NULL.
Do not free or modify the returned data; it belongs to the NET_Address that was queried, and is valid as long as the object lives. Either make sure the address has a reference as long as you need this or make a copy of the bytes.
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.
A human-readable version is available in NET_GetAddressString() and isn't any less efficient to query than the raw bytes.
It is safe to call this function from any thread.
This function is available since SDL_net 3.0.0.