I have improved the client server code communications as the previous iteration was unreliable. Now, instead of both being connected all the time, the server just waits for the client to connect. There are now also timeouts which are handled at both ends. I am actually not sure if what I did is correct. Socket communcations are new to me. It works reliably though.