I open 2 clients, 1 first makes a game room, then the other client joins this room.
10 Game rooms @ 2 Players each
Each player represents a line controlled by keyboard inputs, this line data is sent to the server, stored on the server, then the server returns the other user's line data.
The communication is flawlessly synchronized for about 5 seconds, then the host client freezes and is unresponsive.
The looping communication once the game room is entered is this for the client:
Client:
serverUpdate(){
prepare information into data structure
//send this data structure to server for server-side storage
iResult = send( ConnectSocket, sendbuf, (int)strlen(sendbuf)+2, 0 );
//get other players data
iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
update other player movement with this received data
}
serverUpdate() is called every 30ms
Server:
in thread function:
//after a socket connection is establish and game room joined,
while(true){
iResult = recv(((ClientParams*)lpParam)->getSocket(), recvbuf, recvbuflen, 0);
Receive and store user data
iSendResult = send( ((ClientParams*)lpParam)->getSocket(), temp.c_str(), DEFAULT_BUFLEN, 0 );
Send other user's data
}
These are all blocking-sockets if that makes a difference with no other settings (ie: TCP_NODELAY)