Basic client-server communication fixes

Implemented minimal working server, fixed an issue in the client caused by connecting more than once to the same server.