delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/02/06/01:47:57

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sat, 5 Feb 2005 12:40:59 GMT
Message-Id: <200502051240.j15CevQ32345@webmail.web-mania.com>
Mime-Version: 1.0
From: HelpBytes <helpbytes AT helpbytes DOT co DOT uk>
To: cygwin AT cygwin DOT com
Subject: gethostbyname() problem?
Reply-To: helpbytes AT helpbytes DOT co DOT uk
X-Origin: 213.249.186.82

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019