NET_WaitUntilResolved(3)
π 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
-1tells the library to wait indefinitely β forever and ever, no thoughts, just waiting π«Ά - a timeout of
0just checks the current status and returns immediately, and it's functionally equivalent to callingNET_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β theNET_Addressobject to wait on. the one you're emotionally invested in now. πtimeoutβ number of milliseconds to wait for resolution to complete.-1to wait indefinitely,0to check once without waiting.
β RETURN VALUE β
- returns
NET_SUCCESSif successfully resolved π - returns
NET_FAILUREif resolution failed π - returns
NET_WAITINGif 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
- 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