Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Why use gethostbyname () is the IP 127.0.0.0

I first uname (&myhost) for the mainframe were myhost.nodename
Then gethostbyname (myhost.nodename) was 本机ip, but show the IP 127.0.0.0 is, why? IP addresses is the way I should 192.168.0.35? ? ?

Why use gethostbyname () is the IP 127.0.0.0

Nodename = localhost;
Uname renamed.

Why use gethostbyname () is the IP 127.0.0.0

Gethostname used, do not use uname

Why use gethostbyname () is the IP 127.0.0.0

However, I have been using uname is the hostname of the machine die
Printf ( "nodename:%s\n" myhost.nodename);

Why use gethostbyname () is the IP 127.0.0.0

Does anyone know you?

Why use gethostbyname () is the IP 127.0.0.0

1, the target to ensure a return struct hostent.

2, if there is a number of aliases and addresses will be able to export cycle.


The second reason is your estimate.

Why use gethostbyname () is the IP 127.0.0.0

I have a way to export cycle

Why use gethostbyname () is the IP 127.0.0.0

What is your /etc/hosts documents.

Why use gethostbyname () is the IP 127.0.0.0

Program follows, the translation will be able to export, when output IP 127.0.0.0
#include "Sys/utsname.h>;
#include "Netdb.h>;
#include "Stdio.h>;

Int main (void)
{
Struct hostent *h;
Struct utsname myname;
Char ** addes;
Char *myhost;
If (uname (&myname) "0)
Exit (0);
Printf ( "sysname:%s\n" myname.sysname);
Printf ( "hostname:%s\n" myname.nodename);
Printf ( "release:%s\n" myname.release);
Printf ( "version:%s\n" myname.version);
Printf ( "machine:%s\n" myname.machine);
If ((h = gethostbyname (myname.nodename)) ====== NULL)
Exit (0);
Addes = h->;h_addr_list;
For (; *addes> NULL; *addes++)
Printf ( "IP Address : %s\n", inet_ntoa (**addes));
}

Why use gethostbyname () is the IP 127.0.0.0

Oh, I wonder if he returned to the hosts of the data? /etc/sysconfig/network-scripts/ifcfg-eth0 Not the data? What is the real output of export-use ifconfig IP?

Why use gethostbyname () is the IP 127.0.0.0

I 127.0.0.0 is the original hosts, I changed my real IP (192.9.203.34), the operation will be found a.out output unexpectedly become a 192.255.255.255, which is why?

Why use gethostbyname () is the IP 127.0.0.0

Your environment? ?

Why use gethostbyname () is the IP 127.0.0.0

Redhat 3.2 8.0 +gcc

Why use gethostbyname () is the IP 127.0.0.0

Some Linux and other Unix perhaps the difference between bars. To look at the other systems tested.

Why use gethostbyname () is the IP 127.0.0.0

Redhat /etc/hosts which is like reading the content, adding hostname and ip hosts in the map, then it can gethostbyname

Why use gethostbyname () is the IP 127.0.0.0

You can traverse through the card system, and then select one of the address 127.0.0.1 instead.



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com