Tao.Sdl SDK Documentation

SdlNet.SDLNet_ResolveIP Method 

Resolve the IPv4 numeric address in address->host, and return the hostname as a string.

[Visual Basic]
Public Shared Function SDLNet_ResolveIP( _
   ByRef address As IPaddress _
) As String
[C#]
public static string SDLNet_ResolveIP(
   ref IPaddress address
);

Parameters

address
This points to the IPaddress that will be resolved to a host name. The address->port is ignored.

Return Value

a valid char pointer (string) on success. the returned hostname will have host and domain, as in "host.domain.ext". NULL is returned on errors, such as when it's not able to resolve the host name. The returned pointer is not to be freed. Each time you call this function the previous pointer's data will change to the new value, so you may have to copy it into a local buffer to keep it around longer.

Remarks

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)

Binds to C-function call in SDL_net.h:

            extern DECLSPEC const char * SDLCALL SDLNet_ResolveIP(IPaddress *ip);
            

Example

            // resolve the host name of the address in ipaddress
            //IPaddress ipaddress;
            char *host;
            if(!(host=SDLNet_ResolveIP(IPaddress))) {
                printf("SDLNet_ResolveIP: %s\n", SDLNet_GetError());
            exit(1);
            }
            

See Also

SdlNet Class | Tao.Sdl Namespace | SDLNet_ResolveHost | SdlNet.IPaddress