Added reconnect code for SocketExceptions.