0

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 ??

Arpit
  • 4,259
  • 10
  • 38
  • 43

3 Answers3

3

Note that the new way of doing it is using getaddrinfo see beej guide

Aif
  • 11,015
  • 1
  • 30
  • 44
0

To gethostbyname to work an entry in /etc/hosts to be made ... :) I was missing that thanks for answers.

Arpit
  • 4,259
  • 10
  • 38
  • 43
  • Needing an entry in your hosts file means your DNS server isn't working right. Are you sure that's not the real source of the problem? – Matthew Iselin Nov 05 '09 at 05:56
  • That is the source of problem I passing hostname but there was no entry in /etc/hosts so it was not able to resolve the IP . – Arpit Nov 06 '09 at 10:23
0

If “ping somehost” on the command line works for you, gethostbyname should work, too, when used correctly. Read manpage resolv.conf(5) for details on how to configure name resolution.

If you get ping working but your code still fails, please post an example.

Alexey Feldgendler
  • 1,792
  • 9
  • 17