gethostbyname() problem?

Sun Feb 6 06:47:00 GMT 2005

The following code performs a lookup at a DNS block list,
the DNS has an entry for this, and returns In
Linux using gcc, and in Windows using Visual Studio, this
code works fine, and outputs

However, in cygwin, it simply outputs, it seems
no matter what is in the hostname, if it begins with what looks
like an IP address, it returns it as the result.

It would appear I am using Cygwin Dll Version 1.5.12-1

Unfortunately, I cannot connect to your website the last 24hrs
to check for the proper place, if there is one, to post this message.


$g++ -o lookup lookup.cpp
$ ./lookup.exe

--Code Follows--

#ifdef WIN32
#include <winsock.h>
#include <netdb.h>
#include <iostream>

int main() {
        struct hostent *host;
        #ifdef WIN32
                WSADATA wsa;
        host = gethostbyname("");
        if (host==NULL) {
                std::cout << h_errno;
                return 0;
        for (int i=0;i<4;i++) {
                std::cout << (int)((unsigned char)host->h_addr_list[0][i]) << ".

        #ifdef WIN32

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list