This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gethostbyname() problem?


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

However, in cygwin, it simply outputs 202.149.167.69., 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.

Output:

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

--Code Follows--

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

int main() {
        struct hostent *host;
        #ifdef WIN32
                WSADATA wsa;
                WSAStartup(MAKEWORD(1,1),&wsa);
        #endif
        host = gethostbyname("202.149.167.69.sbl-xbl.spamhaus.org");
        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
                WSACleanup();
        #endif
}





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]