NET_ResolveHostname(3)

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

πŸ’– NET_ResolveHostname πŸ’–

okay bestie, welcome to the SDL_net3 FUNCTIONS section of the manual, and today's main character is NET_ResolveHostname β€” the girl who takes your cute lil human-readable hostname and turns it into something the computer can actually vibe with. πŸ¦‹


✨ NAME ✨

NET_ResolveHostname β€” resolve a human-readable hostname.


✨ SYNOPSIS ✨

#include <SDL3_net/SDL_net.h>

NET_Address * NET_ResolveHostname(const char *host);

✨ DESCRIPTION ✨

so like. SDL_net does not do human-readable hostnames (things like www.libsdl.org, you know, the cute ones) β€” it operates on computer-readable addresses instead. This function is the glow-up translator between the two. That whole process? It's called "resolving" an address. πŸ’…

You can also use this to turn IP address strings (like "159.203.69.7") into NET_Address objects. versatile queen fr fr.

⚠️ lowkey important: resolving an address is an asynchronous operation, because the library has to go ask a server on the internet for the info it needs, and that can take time (and possibly fail later, not now 😭). This function will not block. It either returns NULL (catastrophic failure, we're sobbing) or an unresolved NET_Address. And until the address actually resolves, it can't be used. periodt.

If you want to block until the resolution is finished, you can call NET_WaitUntilResolved(). Otherwise, you can do a non-blocking check with NET_GetAddressStatus(). pick your fighter 🫢

When you are done with the returned NET_Address, call NET_UnrefAddress() to dispose of it. And yes, you need to do this even if resolution later fails asynchronously. no take-backs, no skipping, that's the rule. πŸŽ€


✨ FUNCTION PARAMETERS ✨

  • host β€” the hostname to resolve. πŸ’–

✨ RETURN VALUE ✨

Returns a new NET_Address on success, NULL on error; call SDL_GetError() for details. (aka the receipts. always read the receipts.) πŸ“


✨ THREAD SAFETY ✨

It is safe to call this function from any thread. 🌈 multitasking icon behavior, no cap.


✨ AVAILABILITY ✨

This function is available since SDL_net 3.0.0. it's been here, it's been iconic. πŸ‘‘


✨ SEE ALSO ✨


and that's the whole page bestie!! 🧚 this was pulled from the SDL_net manual, version SDL_net 3.2.0, and yes it was giving NET_ResolveHostname(3) the entire time. slay, go resolve something, mwah πŸ’œπŸŒΈ

πŸ“¦ where this page comes from