Questions tagged [gethostbyname]

140 questions
2
votes
1 answer

PHP gethostbyname returns hostname instead of IP address

I am checking current hosting IP of websites using $ip = gethostbyname('domainname.com'); It Returns IP address of websites working well but for some domains it returns back the domain name $ip =…
Sarjerao Ghadage
  • 1,420
  • 16
  • 31
2
votes
2 answers

getaddrinfo and gethostbyname crashing when called from child thread?

We have created a multithreaded, single core application running on Ubuntu. When we call getaddrinfo and gethostbyname from the main process, it does not crash. However when we create a thread from the main process and the functions getaddrinfo and…
Syed Aslam
  • 79
  • 7
2
votes
1 answer

gethostbyname() processes resolving consistently even from different threads?

I conducted an experiment with DNS resolving by gethostbyname() from different threads. I turned off network link and ran program below. And output was like this gethostbyname started at 1411234734 gethostbyname started at 1411234734 gethostbyname…
Oleg G
  • 925
  • 4
  • 12
2
votes
1 answer

C++ asynchronous hostname resolving

I have a epoll server which sometimes opens outgoing connections, using their hostnames representation. Because of high rate of incoming connections flow, I don't want to block somewhere like getaddrinfo() or gethostbyname(). Sure, I could…
pavelkolodin
  • 2,859
  • 3
  • 31
  • 74
2
votes
1 answer

Modifying gethostbyname (res_search) source code - Linux Ubuntu 14.04 LTS

I am trying to modify the behaviour of the DNS lookup functions in Linux for my project by setting it to write a random string in a file as a test. Linux use some DNS resolver functions, mainly gethostbyname. Looking forward, I found out that the…
Lucas
  • 113
  • 6
2
votes
2 answers

Socket hostname lookup timeout: how to implement it?

I write portable Windows/Linux application that uses sockets. I use gethostbyname function to perform DNS lookups. However, I don't see how to set gethostbyname timeout and secure my application against hanging during name lookup. Of course, it is…
Vitalii
  • 4,434
  • 4
  • 35
  • 77
2
votes
2 answers

Differences between inet_aton() and gethostbyname() in C?

I'm studying C and TCP/UDP. As the title... Is there any difference between inet_aton() and gethostbyname() in C? From what I know, both convert an IP address from a string to a number.
testermaster
  • 1,031
  • 6
  • 21
  • 40
2
votes
1 answer

segfault of malloc_consolidate from gethostbyname

Some background information: I'm working on a group project for my networks class. We are to implement a Key Distribution Center with 3 parts; the KDC itself, an initiator (A) and a responder(B) using c++ with g++ on RedHat 6 servers owned by the…
Spyguy
  • 23
  • 1
  • 3
2
votes
2 answers

gethostbyname() error - something related to memory management

I am trying to use gethostbyname() function in C for a networking assignment. When I try to do this struct hostent *host; char* addr = malloc (10*sizeof(char)); strcpy (addr, "localhost"); host= (struct hostent *) gethostbyname(addr); I get…
Hashken
  • 4,396
  • 7
  • 35
  • 51
1
vote
0 answers

python - socket.gethostbyname() outputting wrong IP Address

socket.gethostbyname('mypcname.local') is giving an IP of 172.23.260.1 which is the IP for WSL on my laptop. However, im expecting to get my wifi ip address in the 192.168.1.0/24 subnet. Is there a way to get the correct IP without disabiling the…
1
vote
1 answer

getaddrinfo expiration value (Linux hostname entries)

I'm writing a linux userspace application that opens a stateless socket (ICMP/UDP) to an internet host The user specifies a hostname FQDN (www.google.com) and I use getaddrinfo (or the old deprecated gethostbyname) function to resolve to an IPv4…
1
vote
1 answer

gethostbynamel() and dns_get_record() returns empty for some domains

I am using a compute instance VM of Google Cloud, have installed Debian 10 and PHP 7.3. Then tried to run this: php -r "print_r(gethostbynamel('2.0.0.127.zen.spamhaus.org.'));" Surprisingly it returns an empty string. However, on any other…
1
vote
1 answer

Where is the source code implementation of gethostbyname() function?

From glibc tree, I can see only file gethstbynm.c (glibc-2.32/inet/gethstbynm.c), but there is no implementation code: #include #include #include #include #include #include…
milanHrabos
  • 2,010
  • 3
  • 11
  • 45
1
vote
2 answers

gethostbyname_r() calls for non-resolvable hosts always returning with h_errnop set to TRY_AGAIN (on Ubuntu 19.04 and 20.04)

while(do_again) { rc = gethostbyname_r(host, &hbuf, tmp, TMPLEN, &hp, &my_h_errno); if (rc != 0) { if(my_h_errno == TRY_AGAIN) { printf("HOST NOT FOUND: got a TRY_AGAIN response from gethostbyname_r()\n"); …
1
vote
1 answer

How can we cache the result of gethostbyname?

My proxy server is spending a lot of time resolving the domain names,is there a way to make gethostbyname cache the result?
DriverBoy
  • 937
  • 1
  • 11
  • 23
1 2
3
9 10