Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

gethostbyname

Posted on 1997-06-17
3
Medium Priority
?
443 Views
Last Modified: 2013-12-23
How to get in C full name of local host, when gethostbyname returns only short one? In aliases too.
I don't want ask DNS in my program. Is field "domain" in /etc/resolv.conf right place to find domain of local host ?
I'm passing name returned by gethostname to gethostbyname.
I want my program to work on any host.
0
Comment
Question by:andzei
3 Comments
 
LVL 1

Expert Comment

by:strobert
ID: 1582153
what are you passing into gethostbyname? "localhost"?
0
 

Author Comment

by:andzei
ID: 1582154
Edited text of question
0
 
LVL 2

Accepted Solution

by:
pxh earned 300 total points
ID: 1582155
Yes. The resolv.conf must contain the name of your local domain. So if you add it to your (short) hostname you will get the full address of your host. However, if a machine is not relying on DNS this file may not be present (see below). But then, there might also no domainname defined on that machine.

Don't try to read /etc/defaultdomain or the output from the command domainname. At least on Solaris machines they may return the NIS domain name, which might be absolutely different from the Internet domain.

Your wish that the application runs on any host is very ambitious. What about a host with networking not set up? Or not using DNS? You may have to specify what the application does and what networking services are essential for it.

Hope this helps,

Peter (pxh@mpe-garching.mpg.de)

0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question