Solved

gethostbyname

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
2 Gateways (bandwidth) - One domain 7 73
Cisco AP to get ip from DHCP 10 75
Internet Protocol Security question 3 71
VPN Connection WIndows 10 5 40
This is an article about my experiences with remote access to my clients (so that I may serve them) and eventually to my home office system via Radmin Remote Control. I have been using remote access for over 10 years and have been improving my metho…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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…

770 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