updated initialization of socket to be wary of lost network.