Questions tagged [gethostbyname]

140 questions
0
votes
0 answers

Using "http" causes segmentation fault in gethostbyname()

This is a weird problem. When I use gethostbyname() in the following example, it works: struct hostent *info = gethostbyname("www.youtube.com"); printf("Host: %s\n",info->h_name); But when I use it with the following, it fails to work: struct…
Vimzy
  • 1,871
  • 8
  • 30
  • 56
0
votes
2 answers

segmentation fault in printing inet_ntoa function

Consider the following program: #include #include #include #include #include #include void printhost(char* pLocalHostAddress ) { struct hostent * pHost; …
pankaj kushwaha
  • 369
  • 5
  • 20
0
votes
0 answers

Problems with static compilation with gethostbyname method

When in my code i use gethostbyname for resolve hostname in a socket program and in the compilation i use -static, like this example gcc -o example -static -ggdb -mpreferred-stack-boundary=2 -fno-stack-protector -z execstack example.c The…
Alex
  • 559
  • 1
  • 4
  • 6
0
votes
2 answers

Why is the program broken down when it runs at if((hptr = gethostbyname(buffer)) == NULL)

This is the server of a socket communication. When the client sends a URL to the server, the server sends the IP to client. When it runs hptr = gethostbyname(buffer), it always returns NULL. Why? Thank you! #include #include…
DaveyTao
  • 33
  • 6
0
votes
2 answers

use gethostbyname() to find IP

what is the correct way to use gethostbyname() in c to retrive the real ip address of the host. Also why would people say DHCP would put this approach in potential danger ?
yuan
  • 317
  • 1
  • 4
  • 12
0
votes
1 answer

Node.js process hangs on SIGTERM if a DNS resolution is in progress

I am using node 10.38 on Linux (Ubuntu 4.10, FC20, etc...). I have some code in startup which looks like: process.on('SIGTERM', function() { process.exit(1); }); process.on('SIGINT', function() { process.exit(1); }); Somewhere else in the…
k2k2e6
  • 510
  • 6
  • 17
0
votes
2 answers

passing char by pointer and getting a different result

I am using gethostname to get the name of the computer I am working on. In my main function I call it and get UBU24-PS-23 the correct name of my computer. Then I call a function and that uses the gethostname and I get a different string. In my…
Aaron
  • 4,380
  • 19
  • 85
  • 141
0
votes
1 answer

gethostbyname not working for external server

I am writing an application with C++ to connect to my server. I am using gethostbyname(). It is working fine when I give host name as 'localhost'. but if i try any other site like google.com, it fails. Can anyone please tell me what could be going…
lucky me
  • 73
  • 1
  • 7
0
votes
1 answer

gethostbyname - h_addr_list incorrect first bit

As the title states that data I am getting back from gethostbyname seems to have a mangled first bit. Here is a short example: struct hostent* host= gethostbyname("indiana.cs.rit.edu"); if (!host) exit(-1); printf("%d.%d.%d.%d\n",…
Freddy
  • 2,249
  • 1
  • 22
  • 31
0
votes
1 answer

gethostbyname() and valgrind

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:…
Zenet
  • 6,961
  • 13
  • 38
  • 45
0
votes
3 answers

DNS resolution fails for ethernet in my Android device(android 4.4.2)

I am trying to enable wired ethernet on my device which runs on android 4.4.I am successful in getting the eth0 interface up. But DNS resolution is not happening.Pinging the address from adb works fine.(if I connect to my router once through WiFi…
0
votes
1 answer

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…
bdhar
  • 21,619
  • 17
  • 70
  • 86
0
votes
1 answer

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…
John
  • 1,974
  • 2
  • 25
  • 32
0
votes
3 answers

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…
WildCrustacean
  • 5,896
  • 2
  • 31
  • 42
0
votes
1 answer

Powershell script error processing CSV data

I'm writing a script to load computer names from a CSV file, then look up their IP addresses. The script creates an error when using the name from the CSV. If I run the script in ISE, the error shows up, but the result still comes though. If I run…
Stanton
  • 65
  • 1
  • 9