diff options
author | chatty | 1994-07-06 11:04:29 +0000 |
---|---|---|
committer | chatty | 1994-07-06 11:04:29 +0000 |
commit | 65ae6594970cc1b0851a84d9481c29897c40d84b (patch) | |
tree | a35a7ce876fe16c2ee26ce19f06241c5da544e94 /comm/Address.cc | |
parent | 64e63aedc6a870046360f108424c7ae3f525596a (diff) | |
download | ivy-league-65ae6594970cc1b0851a84d9481c29897c40d84b.zip ivy-league-65ae6594970cc1b0851a84d9481c29897c40d84b.tar.gz ivy-league-65ae6594970cc1b0851a84d9481c29897c40d84b.tar.bz2 ivy-league-65ae6594970cc1b0851a84d9481c29897c40d84b.tar.xz |
gethostbyname -> uname
Diffstat (limited to 'comm/Address.cc')
-rw-r--r-- | comm/Address.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/comm/Address.cc b/comm/Address.cc index af2e1ae..03391d7 100644 --- a/comm/Address.cc +++ b/comm/Address.cc @@ -20,6 +20,9 @@ #include <unistd.h> #include <stdio.h> #include <memory.h> +#if 1 +#include <sys/utsname.h> +#endif #ifdef __osf__ extern "C" { #endif @@ -326,10 +329,20 @@ UchInetAddress :: LoopBack () return loopback; struct hostent *host; - char name [128]; - + +#if 0 + char name [128]; gethostname (name, sizeof (name)); host = gethostbyname (name); +#else + struct utsname un; + if (uname (&un) < 0) { + Error (ErrFatal, "address", "cannot get name of local host"); + return 0; + } + host = gethostbyname (un.nodename); +#endif + if (! host) { Error (ErrFatal, "address", "cannot get address of local host"); return 0; |