Article View: borland.public.cppbuilder.nativeapi
Article #1960gethostbyaddr() does not return any info
From: Kris
Date: Tue, 15 May 2007 08:46
Date: Tue, 15 May 2007 08:46
32 lines
1452 bytes
1452 bytes
Hi,
I'm attempting to obtain the NetBIOS name of given IP address (which is
a NAS device in my LAN).
However, the gethostbyaddr() call always returns NULL and the
WSAGetLastError() returns 6 (=WSA_INVALID_HANDLE).
Does anybody know what I'm doing wrong ? The code below shows following
output:
Address=1711280300
RemoteHost=00000000
Error=6
struct hostent* RemoteHost;
unsigned int Address;
char host_name[]="172.16.0.102";
Address=inet_addr(host_name);
DEBUG("Address=%d",Address);
RemoteHost=gethostbyaddr((char*)&Address,4,AF_INET);
DEBUG("RemoteHost=%08X",RemoteHost);
int Error=WSAGetLastError();
DEBUG("Error=%d",Error);
Thanks,
Kris
Technical Details
Message-ID:
<46497388$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d22c882963cf68b8,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 15 May 2007 10:46:51 +0200 From: Kris <test@test.com> User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: gethostbyaddr() does not return any info Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.242.6.168 Message-ID: <46497388$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1179218824 81.242.6.168 (15 May 2007 01:47:04 -0700) Lines: 32 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail