Back to libut API Reference


SYNOPSIS

    #include "libut/ut.h"
    char* UT_net_resolve( char *hostname );


DESCRIPTION

This function accepts a DNS hostname (e.g. ``www.w3c.org'') and returns a pointer to a static string representation of the corresponding IP address (e.g., ``128.30.52.25'').

PORT SUFFIX FEATURE

This function permits the hostname to have a suffix of the form ``:port'' where port is a numeric TCP port number. It will be ignored for the purpose of the DNS lookup, but appended back to the output string. E.g.,

    s = UT_net_resolve( "www.w3c.org:80" );  
    /* s is now "128.30.52.25:80" */

This feature is designed to help build the ``ip:port'' string argument used by such functions as UT_net_connect(3), UT_net_listen(3) and UT_net_request(3).


RETURN VALUE

The return value is a NULL pointer if the hostname lookup failed. Otherwise it is a pointer to a static string representation of the IP address. The caller should copy the returned string if it needs to be retained, since each time this function is called it will be overwritten.


NOTES

The DNS lookup is implemented as a blocking operation. A non-blocking version of this function may be added to libut later, which would invoke a callback upon completion of the DNS lookup.


SEE ALSO

UT_net_connect(3), UT_net_listen(3), UT_net_request(3)


AUTHOR

Troy D. Hanson <thanson@users.sourceforge.net>