Implemented socket calls to server.