Thank you master
We have to call gethostbyname() on the result of gethostname() because the two aren’t guarenteed to be the same name for the same host: on some losing systems, one is a FQDN and the other is not. Here in the wide wonderful world of Unix it’s rocket science to obtain the local hostname in a portable fashion.
And don’t forget, gethostbyname() reuses the structure it returns, so we have to copy the f*cker before calling it again. Thank you master, may I have another.