[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.1 SDLNet_ResolveHost

int SDLNet_ResolveHost(IPaddress *address, const char *host, Uint16 port)

This points to the IPaddress that will be filled in. It doesn't need to be set before calling this, but it must be allocated in memory.
For connecting to a server, this is the hostname or IP in a string.
For becoming a server, this is NULL. If you do use NULL, all network interfaces would be listened to for incoming connections, using the INADDR_ANY address.
For connecting to a server, this is the the servers listening port number.
For becoming a server, this is the port to listen on.
If you are just doing Domain Name Resolution functions, this can be 0.

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)

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.

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);

See Also:
3.2.2 SDLNet_ResolveIP, 4.1 IPaddress

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on November, 3 2009 using texi2html