Handle error if gethostbyname fails

handling gethostname() isn't enough