Questions tagged [gethostbyname]
140 questions
4
votes
2 answers
gethostbyname dual network interfaces, select which one to use
I have a c-program that needs to connect to a server and send a tcp payload and wait for the response. This works well for normal use but since I have two different network interfaces, let us call them if0 and if1 on the computer running the…

www.jensolsson.se
- 3,023
- 2
- 35
- 65
3
votes
1 answer
socket.gethostbyname doesn't behave well
I'm using gethostbyname function for DNS and IP addresses checking. However, it does not work well in this case:
>>> from socket import gethostbyname
>>> gethostbyname('lns.sa')
'67.215.65.132'
>>> gethostbyname('lns.sa')
Traceback (most recent call…
user1129665
3
votes
3 answers
process-local override of name resolution?
I have test code that I want to have a couple of hostnames resolve to the loopback while testing. When deployed, this code will use the normal system name resolution as appropriate. Test and deployment host are recent linux distros (SLES11SP1,…

Brian Cain
- 14,403
- 3
- 50
- 88
3
votes
2 answers
gethostbyname() only returns the address of local host on linux
I'm trying to portably (Windows & Linux) find all of the IP addresses of the local machine. The method I am using is to first call gethostname(), and then pass the result of that to gethostbyname(), which returns an array of ip addresses.
The…

dicroce
- 45,396
- 28
- 101
- 140
3
votes
4 answers
gethostbyname() function returns empty buffer
I am new to internet programming, and I am trying to use the gethostbyname() function. When I input a string such as "www.yahoo.com" to gethostbyname function it works fine, but when I input a char array, it will always return an empty buffer.
…

BVBC
- 375
- 2
- 4
- 11
3
votes
2 answers
gethostbyname creates a thread?
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…

VSC
- 387
- 2
- 4
- 15
3
votes
1 answer
gethostbyname fails with hostname from gethostbyaddr, which succeeded
I have following script:
#include
#include
#include
#include
#include
const char *ip="190.162.1.2";
int main(int argc, const char * argv[])
{
in_addr host_addr;
hostent *addr=0;
…
user704565
3
votes
1 answer
gethostbyname/getaddrinfo keeps failing, even when internet connection is up
Background
We have a small headless box running Linux kernel 2.6.35 and some variant of Open Embedded distribution on ARM hardware.
As far as we can tell we are using glibc 2.10.1.
The box has an unconnect ethernet and a serial attached GSM/3G…

Nicolai Henriksen
- 1,324
- 1
- 13
- 37
3
votes
1 answer
Python networking extremely slow
I have two servers (let me name them A and B).
Facts:
They have same CPU, memory, motherboard, hard drive, uplink speed.
They are both on Ubuntu 12.04 with Python 2.7.3 and Django latest revision.
They also locate in the same data center with same…

jack
- 17,261
- 37
- 100
- 125
3
votes
1 answer
h_addr_list order
I want to understand in which order are the elements of h_addr_list sorted when I get the hostent from gethostbyname.
Basically, I'm working on a very old function that gets a hostent struct from gethostbyname, and returnes h_addr to the caller. I'm…

Neowizard
- 2,981
- 1
- 21
- 39
2
votes
2 answers
How to use gethostbyname in c
I'm trying to use the function gethostbyname, but my code:
int handleTCP(char *hostname, char* portNo){
struct hostent *hp = gethostbyname(hostname);
...
}
Keeps returning:
21: warning: initialization makes pointer from integer without a…

KWJ2104
- 1,959
- 6
- 38
- 53
2
votes
1 answer
Erlang: Why does inet:gethostbyname deliver 2 addresses whereas inet:getaddr delivers just one
The problem
I used inet:gethostbyname(Hoststr) in a docker environment with a couple containers for over a year without problems. Due to non recoverable read errors on the SSD which -- according to the provider -- is perfectly fine I was forced to…

kklepper
- 763
- 8
- 13
2
votes
1 answer
Get IP from URL (C++)
How can I get the IP-address from a domain name with the top level domain name?
In this example get the IP of google.com.
And if possible in IPv6 in the correct format.
This is what I've tried so far:
#include
using namespace std;
int…

UnhandledException321
- 133
- 1
- 1
- 11
2
votes
2 answers
Delphi GetHostByName equivalent for firemonkey?
Is there any GetHostByName equivalent for firemonkey, which works for Desktop Win32/Win64/Mac?
user7415109
2
votes
0 answers
Why does gethostbyname() intermittently give HOST_NOT_FOUND for hostname?
On Mac OS X El Capitan, I am running a C++ application that calls gethostbyname() and sometimes passes the argument string matching the current machine:
bash-3.2$ hostname
Ws-MacBook-Pro
This normally works, however, on rare occasions, I get a NULL…

WilliamKF
- 41,123
- 68
- 193
- 295