SDLNet_ResolveHost
Name
SDLNet_ResolveHost -- Get an IPaddress from hostname.
Synopsis
int SDLNet_ResolveHost(IPaddress *address, char *host, Uint16 port);
Description
SDLNet_ResolveHost resolve the string host, and fill in the IPaddress pointed to by address with the resolved IP and the port number passed in through port. This is the best way to fill in the IPaddress struct for later use. This function does not actually open any sockets, it is used to prepare the arguments for the socket opening functions.
Warning: this function will put the host and port into Network Byte Order into the address fields, so make sure you pass in the data in your hosts byte order. (normally not an issue)
Return Value
Returns 0 on success. -1 on errors, plus address.host will be INADDR_NONE. An error would likely be that the address could not be resolved.
Example
For a server listening on all interfaces, on port 1234:
// create a server type IPaddress on port 1234 IPaddress ipaddress; SDLNet_ResolveHost(&ipaddress, NULL, 1234);
For a client connecting to "host.domain.ext", at port 1234:
// create an IPaddress for host name "host.domain.ext" on port 1234 // this is used by a client IPaddress ipaddress; SDLNet_ResolveHost(&ipaddress, "host.domain.ext", 1234);
