Solved

gethostbyname

Posted on 1997-06-17
3
429 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 100 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Lets look at the default installation and configuration of FreeProxy 4.10 REQUIREMENTS 1. FreeProxy 4.10 Application - Can be downloaded here (http://www.handcraftedsoftware.org/index.php?page=download) 2. Ensure that you disable the windows fi…
What’s a web proxy server? A proxy server is a server that goes between clients and web servers, used in corporate to enforce corporate browsing policy and ensure security. Proxy servers are commonly used in three modes. A)    Forward proxy …
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now