Hi I'm writing a simple game where clients connect to the server and can see each other on a small board moving around. The server is running on my local machine and my friend that lives in another town connects to the server via my public ip address. I works but my friends movement is very choppy f.ex if he hits a button to move to right a several times in a short period his movement is seen by him and myself as a one long step to the right instead of a several small steps. Now I realize that there are bound to be some latency but I'm wondering how I can write my code to minimize it.
Currently the arrangement is non-persistent connection i.e the client requests a tcp socket transaction with the server for each command, afterwards that connection is closed. For example to move to the left the client must request a tcp socket connection with the server, send him the command (i.e move one square to the left) the server responds with an 'ok' and terminates the connection.
Could it be more appropriate to keep the connection open i.e the client is always connected to the server as in persistent connection? If so the server would have to maintain each of the client's socket on a seperate thread, since the server is in a endless loop listening for incoming connections?
I have another question but I will include it in another post, thank you.