Minor fixes / changes

Allow user to specify timeout, set the timeout before trying to connect,
added error handling if the domain couldn't be resolved