A gotcha to keep in mind: a machine can have multiple IP addresses (even if it only has a single interface!). If you donīt go via the hostname, be sure to allow the user or admin to override your IP detection.
Makeshifts last the longest.
Comment on Re: finding ip address without hostname