[omniORB] Re: gethostbyname/addr on win32.

Lai, Patrick Patrick.Lai@broadvision.com
Thu Dec 19 19:13:01 2002


I'm not sure if this is completely a Windows specific issue.  I think "nslookup <ipaddr>" on Unix would also fail if there is no reverse DNS entry for <ipaddr>.  One may argue that it is a DNS configuration problem that should be fixed by the network administrator.  On the other hand, if there is a reliable way to handle a common misconfiguration problem, it will make the product more friendly.

One thing that's worked for us is adding a line to winnt\system32\driver\etc\hosts that maps an address to itself.  (TCP/IP would also be configured to consult the hosts file.)  That's sometimes easier than getting the admin people to fix the DNS configuration.

-- Patrick Lai

> -----Original Message-----
> From: jon.kristensen@kongsberg-simrad.com
> [mailto:jon.kristensen@kongsberg-simrad.com]
> Sent: Thursday, December 19, 2002 4:03 AM
> To: Daniel.Bell@colorbus.com.au
> Cc: omniorb-list@omniorb-support.com
> Subject: [omniORB] Re: gethostbyname/addr on win32.
> 
> 
> On Thu, 19th Dec 2002 Daniel Bell wrote:
> 
> >However, if the win32 machine does not have a reverse DNS 
> entry for it in
> >the DNS, then the host information is failed to be retrieved.
> 
> I have made several posts to this list about the same problem 
> over the past
> year, the last one on December 12th titled: "Re: [omniORB] 
> ETS issues for
> upcoming 4.0 release"
> 
> You may not have observed these posts, because many of them 
> deals with ETS
> issues. The ETS real-time kernel is win32 compatible, and I do ETS
> development and debugging using Microsoft Visual Studio. As 
> none of my ETS
> machines have DNS enabled, I have run into the same probles 
> as you have.
> unfortunately, I initially though this to be an ETS specific 
> problem, hence
> the titles of the posts.
> 
> I have proposed a simple patch that solves this, and repeated 
> this proposal
> several times, last time in my post december 12th as an 
> attempt to get it
> into the 4.0.1 release. I have not yet seen any response to 
> that last post.
> 
> The patch is changing all the time as the source code also 
> changes. Based
> on the snapshot from november 17th, the patch is now:
> 
> replace the code line libcWrapper.cc:213
> 
>       hp = ::gethostbyaddr((char*)&IP, sizeof(IP), AF_INET);
> 
> with:
> 
>       {
>          // Fake a hostent structure based on our IP address
>          static char * Aliases[1] = { NULL };
>          static unsigned long * Adresses[2] = { &IP, NULL };
> 
>          hp = &myhp;
>          hp->h_name      = (char*)name;
>          hp->h_aliases   = (char**)Aliases;
>          hp->h_addrtype  = PF_INET;
>          hp->h_length    = 4;
>          hp->h_addr_list = (char**)Adresses;
>       }
> 
> This patch skips the gethostbyaddr call and instead fakes a hostent
> structure that has the correct h_addr field and has the 
> h_name field set to
> the dotted decimal string. The only things actually used 
> further down-line
> are these two fields, so this patch works perfectly.
> 
> I have been using this patch (or something similar) on ETS, NT4 and on
> Win2k all the way since this part of the omniORB code were rewritten
> heavily just less than a year ago. Never had any problems.
> 
> I hope we now can get this or something similar into the 
> sources so I no
> longer have to edit and recompile every time a new snapshot 
> is downloaded.
> 
> Regards,
> Jon Kristensen
> 
> 
> --------------
> Jon Kristensen
> Principal Engineer, SW Embedded Systems
> Kongsberg Simrad AS, Horten, Norway
> phone:      +47 33 02 39 34
> fax:  +47 33 04 76 19
> email:      jon.kristensen@kongsberg-simrad.com
> 
> 
> 
> _______________________________________________
> omniORB-list mailing list
> omniORB-list@omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list
>