tags 472001 + moreinfo
thanks

* David Bremner <[EMAIL PROTECTED]> [2008-03-21 18:27]:
> Although the documentation says hostnames are supported, specifying 
> "server = localhost" does not work, although 
> "server = 127.0.0.1" does

How do you notice that it does not? Cause it works fine 
here. Looking at the code I see also no reason why this 
should not work:

unsigned int resolve_ip(char *host, int showmsg, int allownames) {
        struct hostent *new;
        unsigned int    hostaddr;
        struct in_addr *ip;

        if ((hostaddr = inet_addr(host)) == (unsigned int) -1) {
                /* We couldn't convert it as a numerical ip so */
                /* try it as a dns name                        */
                if (allownames) {
                        #ifdef HAVE_GETHOSTBYNAME
                        if ((new = gethostbyname(host)) == (struct hostent *) 
0) {
                        #endif
                                return(-1);
                        #ifdef HAVE_GETHOSTBYNAME
                        } else {
                                ip = ((struct in_addr *) * new->h_addr_list);
                                hostaddr = ip -> s_addr;
                                if (showmsg) 
                                        printf("Connecting to %s...\n", 
inet_ntoa(*ip));
                        }
                        #endif
                } else
                        return(-1);
        }

        return (hostaddr);
}

So if the address is no numerical address (inet_addr(host)) gethostbyname
is used to resolve it.

Kind regards
Nico

-- 
Nico Golde - http://www.ngolde.de - [EMAIL PROTECTED] - GPG: 0x73647CFF
For security reasons, all text in this mail is double-rot13 encrypted.

Attachment: pgpViU9fTkTYZ.pgp
Description: PGP signature

Reply via email to