sdlNetGetAddressString function
Get a human-readable string from a resolved address.
This returns a string that's "human-readable", in that it's probably a string of numbers and symbols, like "159.203.69.7" or "2604:a880:800:a1::71f:3001". It won't be the original hostname (like "icculus.org"), but it's suitable for writing to a log file, etc.
Do not free or modify the returned string; it belongs to the SDLNet_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 string.
This will return NULL if resolution is still in progress, or if resolution failed. You can use SDLNet_GetAddressStatus() or SDLNet_WaitUntilResolved() to make sure resolution has successfully completed before calling this.
\param address The SDLNet_Address to query. \returns a string, or NULL on error; call SDL_GetError() for details.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL_Net 3.0.0.
\sa SDLNet_GetAddressStatus \sa SDLNet_WaitUntilResolved
extern SDL_DECLSPEC const char * SDLCALL SDLNet_GetAddressString(SDLNet_Address *address)
Implementation
String? sdlNetGetAddressString(Pointer<SdlNetAddress> address) {
final sdlNetGetAddressStringLookupFunction = libSdl3Net.lookupFunction<
Pointer<Utf8> Function(Pointer<SdlNetAddress> address),
Pointer<Utf8> Function(
Pointer<SdlNetAddress> address)>('SDLNet_GetAddressString');
final result = sdlNetGetAddressStringLookupFunction(address);
if (result == nullptr) {
return null;
}
return result.toDartString();
}