If the host is not reachable connect don't return thus the program is locked. A non-blocking connect with a timer should be implemented.