gethostbyname

how to write a program to report the local IP address such as 192.168.1.102?

since my Linksys router doesn't assign a fixed local IP to the computers (PC and Mac and Linux), i'd like to write a script so that every minute, the computers will update to each other so that http://localhost/list.html on each machine will contain a list of names of all PC and Mac and a link to their apache server (pointing to http:/...

gethostbyname problem

I wish to use "gethostbyname" in my Suse m/c but it is not returning any structure. but on the other systems it is working fine what could be the issue with my m/c ?? ...

Asynchronous address resolution in winsock?

Looking into asynchronous address resolution in winsock it seems that the only two options are either to use the blocking gethostbyname on a seperate thread, or use WSAAsyncGetHostByName. The latter is designed for some reason to work with window messages, instead of overlapped operations and completion ports/routines. Is there any vers...

Python attribute error: type object '_socketobject' has no attribute 'gethostbyname'

Hi Everyone, I am trying to do this in my program: dest = socket.gethostbyname(host) I have included the line from socket import * in the beginning of the file I am getting an Attribute Error that says: AttributeError: type object '_socketobject' has no attribute 'gethostbyname' I really do not understand what I need to...

Issue with gethostbyname on 64-bit Windows

I am trying to migrate some code from 32-bit Windows (XP and Server 2003) to 64-bit Windows 7, and I am having a weird problem with gethostbyname. I'm doing something like this: struct hostent *hp; hp = gethostbyname( host ); After the call to gethostbyname, the pointer hp->h_addr_list is invalid. It has all the right numbers, but i...

gethostbyname fails for local hostname after resuming from hibernate (Vista+7?)

Just wondering if anyone else has spotted this: On some user's machines running our software, occasionally the call to Win32 winsock gethostbyname fails with error code 11004. For the argument to gethostbyname, I'm passing in the result from gethostname. Now the docs say 11004 is WSANO_DATA. None of the descriptions seem to be relevan...

WSAGetLastError with unknown error code.

I am using WSAGetLastError function to retrieve failure details when using getHostByName function. But the error code returned by the function is 0042124C is not available in the documentation. Am I receiving the error code in some other format or am I using the function in a faulty way? Thanks. PS. Code segment below // DNS Hostname....

gethostbyname() and valgrind

Hello, I keep getting this error whenever I call gethostbyname() in my C code. ==7983== Invalid read of size 1 ==7983== at 0x412AB2C: ____strtoul_l_internal (strtol_l.c:298) ==7983== by 0x412A46F: strtoul (strtol.c:110) ==7983== by 0x41D427E: inet_aton (inet_addr.c:143) ==7983== by 0x41D8FF3: __nss_hostname_digits_dots (digi...

Is gethostbyname guaranteed to return hostent structures with IPv4 addresses?

I cannot use getaddrinfo(...) for resolving hostnames and therefore must stick to gethostbyname(...) Is the gethostbyname(...) function guaranteed to return hostent structures that contain only IPv4 (AF_INET) addresses on success, so that the following code would always lead to an IPv4 address: int resolve(const char *name, struct in_a...

gethostbyname in C

I don't know how to write applications in C, but I need a tiny program that does: lh = gethostbyname("localhost"); output = lh->h_name; output variable is to be printed. The above code is used in PHP MongoDB database driver to get the hostname of the computer (hostname is part of an input to generate an unique ID). I'm skeptical that...

gethostbyname creates a thread??

Hello, I am working in C++ with VS2008 and Win7. While examining a program I was following the threads created, and it seems that gethostbyname() creates a thread for itself. Could you explain why? On msdn is says: "The memory for the hostent structure returned by the gethostbyname function is allocated internally by the Winsock DLL...

Python urllib2: gethostbyname

I need to get requested host's ip address using urllib2 like import urllib2 req = urllib2.Request('http://www.example.com/') r = urllib2.urlopen(req) Is there any issues like ip = urllib2.gethostbyname(req)? Sultan ...