NET_ResolveHostname - Man Page

Resolve a human-readable hostname.

Synopsis

#include <SDL3_net/SDL_net.h>

NET_Address * NET_ResolveHostname(const char *host);

Description

SDL_net doesn't operate on human-readable hostnames (like www.libsdl.org but on computer-readable addresses. This function converts from one to the other. This process is known as "resolving" an address.

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

Note that resolving an address is an asynchronous operation, since the library will need to ask a server on the internet to get the information it needs, and this can take time (and possibly fail later). This function will not block. It either returns NULL (catastrophic failure) or an unresolved NET_Address. Until the address resolves, it can't be used.

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().

When you are done with the returned NET_Address, call NET_UnrefAddress() to dispose of it. You need to do this even if resolution later fails asynchronously.

Function Parameters

host

The hostname to resolve.

Return Value

Returns A new NET_Address on success, NULL on error; call SDL_GetError() for details.

Thread Safety

It is safe to call this function from any thread.

Availability

This function is available since SDL_net 3.0.0.

See Also

NET_WaitUntilResolved(3), NET_GetAddressStatus(3), NET_RefAddress(3), NET_UnrefAddress(3)

Referenced By

NET_Address.3type(3).

SDL_net 3.2.0 SDL_net3 FUNCTIONS