Cons thread.

Removed unused toServer var.
Fixed problem where connections fails and system sits in a loop trying
to read data from the socket. System can now close the socket and try
again.