NET_WaitUntilResolved(3)

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

πŸ’– NET_WaitUntilResolved(3) πŸ’–

okay bestie, welcome to the SDL_net3 FUNCTIONS section of the manual β€” yes this is the one, the NET_WaitUntilResolved(3) page, and it's lowkey a banger. sit down, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

NET_WaitUntilResolved β€” block until an address is resolved. that's it, that's the whole vibe: you sit there and you WAIT. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3_net/SDL_net.h>

NET_Status NET_WaitUntilResolved(NET_Address *address, Sint32 timeout);

πŸ¦‹ DESCRIPTION πŸ¦‹

so, the NET_Address objects that NET_ResolveHostname hands you? they take a minute to do their thing. like, they're doing their work _asynchronously_ instead of making your whole program sit around for an indefinite amount of time. iconic of them honestly. ✨

but β€” plot twist β€” if you actually want your program to sleep until the address resolution is done? you can just call this function. no cap.

this function takes a timeout value, in milliseconds, for how long to wait for resolution to complete. here's the tea:

  • a timeout of -1 tells the library to wait indefinitely β€” forever and ever, no thoughts, just waiting 🫢
  • a timeout of 0 just checks the current status and returns immediately, and it's functionally equivalent to calling NET_GetAddressStatus.
⚠️ resolution can fail after some time (the DNS server took a while to reply that the hostname isn't recognized, etc.), so be sure to check the result of this function instead of just assuming it worked! fr fr, don't do that to yourself. 😭

once an address is successfully resolved, it can be used to connect to the host represented by the address. slay. πŸŽ€

and if you don't want your program to block at all? no problem β€” you can call NET_GetAddressStatus from time to time until you get a non-zero result. main character energy, non-blocking edition. πŸ‘‘


πŸ’œ FUNCTION PARAMETERS πŸ’œ

  • address β€” the NET_Address object to wait on. the one you're emotionally invested in now. πŸ’–
  • timeout β€” number of milliseconds to wait for resolution to complete. -1 to wait indefinitely, 0 to check once without waiting.

⭐ RETURN VALUE ⭐

  • returns NET_SUCCESS if successfully resolved πŸŽ‰
  • returns NET_FAILURE if resolution failed πŸ’€
  • returns NET_WAITING if it's still resolving (this function timed out without resolution) ⏳

and if you get NET_FAILURE, call SDL_GetError() for details. she'll tell you what went wrong.


🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread, and several threads can block on the same address simultaneously. yes, they can all wait together. it's giving group chat. πŸ«‚


πŸ’… AVAILABILITY πŸ’…

this function is available since SDL_net 3.0.0. it's been here, it's been that girl. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯


and that's the page, bestie! this little manual moment came to you courtesy of the SDL_net manual, version 3.2.0, and yes it's NET_WaitUntilResolved(3) β€” go forth, resolve those addresses, and don't forget to check your return value. mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from