modify to output error message and require input again when could not connect to server.