- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- gethostbyname fails with unknown error
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 03:51 AM
12-18-2001 03:51 AM
We are facing a problem with gethostbyname() in our application code. It returns NULL and the h_errno is set to zero.
/etc/nssswitch.conf file looks ok.
/etc/hosts file has an entry for the local machine.
What could be the possible reasons for such a behaviour?
Is this problem introduced by any HP-UX patch?
Also, if we gethostbyname returns correct information if IP address is being passed as a parameter.
Also a simple program as the folloing returns the correct values:
#include
#include
main(int argc, char** argv)
{
struct hostent *infoPtr;
infoPtr = gethostbyname(argv[1]);
if(!infoPtr){
fprintf(stderr, "error! \n");
}
else{
fprintf(stdout, "h_name: %s\n", infoPtr->h_name);
fprintf(stdout, "h_addrtype: %d\n", infoPtr->h_addrtype);
}
}
Any help would be appreciated.
Thanks and Regards,
Medha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 03:53 AM
12-18-2001 03:53 AM
Re: gethostbyname fails with unknown error
nslookup on the same hostname?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 03:57 AM
12-18-2001 03:57 AM
Re: gethostbyname fails with unknown error
-r--r--r-- 1 root sys 41 Jun 2 16:23 /etc/resolv.conf
should be as above
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 04:10 AM
12-18-2001 04:10 AM
Re: gethostbyname fails with unknown error
We have already checked for these two things. They are fine. Thus, we dont understand is why the sample program works and the application program does not?
Thanks and Regards,
Medha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 04:18 AM
12-18-2001 04:18 AM
Re: gethostbyname fails with unknown error
If the C code you showed is working and the application is not working, the problem could be something related to your application.
Does this application work on other systems? or was it ever working on this box?
What is the exact error it returns?
-raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 04:48 AM
12-18-2001 04:48 AM
Re: gethostbyname fails with unknown error
The code was previously compiled on HP-UX 11.00 OS and a 32-bit box.
Following was the environment:
$ what `which CC`
/bin/CC:
HP C++ HPCPLUSPLUS A.12.00 (971008) AR
$ what /usr/lib/libc.a
/usr/lib/libc.a:
$ PATCH/11.00:PHCO_15768 Jun 26 1998 15:29:51 $
Now we are attempting a build on HP-UX 11.00 and a 64-bit box.
Following is the environment on this machine:
$ what `which CC`
/home/medha/bin/CC:
HP C++ HPCPLUSPLUS A.12.14 (980921)
$ what /usr/lib/libc.a
/usr/lib/libc.a:
$ PATCH/11.00:PHCO_23770 Mar 29 2001 11:10:50
The code compiled on the 32-bit box worked fine on both the 32-bit and 64-bit boxes.
The 32-bit code being compiled on 64-bit box fails. gethostbyname results in an error. The h_errno for the function is zero.
Thanks and Regards,
Medha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 05:41 AM
12-18-2001 05:41 AM
Re: gethostbyname fails with unknown error
Do a nslookup and see that the hostname resolution is working okay on your system.
nslookup
> system_name
> system_ip_add
>exit
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 06:02 AM
12-18-2001 06:02 AM
Re: gethostbyname fails with unknown error
We have already checked the nslookup output. It is fine.
Regards,
Medha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 06:14 AM
12-18-2001 06:14 AM
Solutionhttp://europe-support.external.hp.com/cki/bin/doc.pl/sid=664f46e90e024acf9b/screen=ckiDisplayDocument?docId=200000057171900
Are you mixing archive & shared libraries while using libpthread? If so ensure you link with the shared version of libpthread with -l:libpthread.1.
Regards,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2001 09:48 PM
12-18-2001 09:48 PM
Re: gethostbyname fails with unknown error
Thanks for the pointer. It solved our problem.
Thanks and Regards,
Medha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2003 06:34 PM
07-07-2003 06:34 PM
Re: gethostbyname fails with unknown error
GetHostByName fails.
Can someone access the link given above (for Europe) as I can not - maybe this link can help me.
Thanks in advance
PA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2003 06:56 PM
07-07-2003 06:56 PM
Re: gethostbyname fails with unknown error
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2003 08:47 PM
07-07-2003 08:47 PM
Re: gethostbyname fails with unknown error
thanks for your response, but nslookup and nsquery all work.
When I write a small program to test gethostbyname it works too.
Its only when its in my application it fails.
Very similar to the earlier problem by Sandeep.
I think that link above may help but I can't access it (it says login failed). I was wondering if anyone can get there and if so and relay the info back to me.
Thanks again in advance
PA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2003 10:22 PM
07-07-2003 10:22 PM
Re: gethostbyname fails with unknown error
Check the /etc/nsswitch.conf file
over there host resolution should files, dns, nis .......
check the /etc/resolve.conf file
system uses the any name server host resolution
pls remove the entry
to check the host resolution from the /etc/hosts file use the nslookup or hosts utility
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2003 12:04 AM
07-08-2003 12:04 AM
Re: gethostbyname fails with unknown error
1. nsswitch.conf reads files, files, files ( i changed it in sam to be make sure it only reads from /etc/hosts).
2. /etc/resolve.conf does not exist. This is a system with only 2 servers allowed on the network. We are not using any DNS etc.
3. nslookup works well too. It returns the ip address of the host. Its only the gethostbyname() function not working.
I have written a small C program it gethostbyname() works well. When its in the main application it does not work.
I am going to start a new thread so I can assign points.