I have a little problem in the application I should write. I have to write a simple Tic-Tac-Toe game with the client server model using UNIX domain sockets. I thought that it would be a good solution if I had one client per player (total of two players) but now I have a problem in synchronizing them. How can the server distinguish between the first and the second client when keeping track of the moves of the players? More specific: How can I synchronize the two clients in such a way that the first one connected to the server will take the first move, then the second one, the first one again and so on? I didn't use a multithreaded server because I only have two players.
I would appreciate any help and suggestions!
The quadruplet (SrcIP, SrcPort, DstIP, DstPort)
is a unique identifier for each connection. Map it into some playerId
. use that Id whenever you encounter a received packet.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.