Skip to content

Prints the local hostname as Java would resolve it on Linux.

License

Notifications You must be signed in to change notification settings

molnarp/javahostname

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

javahostname

Prints the local hostname as Java would resolve it on Linux.

This program simulates how the local hostname is resolved in the OpenJDK Java 8 runtime, as outlined below.

  1. resolve local hostname with gethostname(2)
  2. resolve ip address belonging to the hostname you got in step 1 with getaddrinfo(3)
  3. resolve canonical hostname for the ip address with getnameinfo(3)

Installation

  1. generate build scripts (used autoconf 2.69)
$ autoreconf --install
  1. configure and build
$ ./configure
$ make
  1. run program
$ src/javahostname

Further reading

man 2 gethostname
man 3 getaddrinfo
man 3 getnameinfo

About

Prints the local hostname as Java would resolve it on Linux.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published