insipx/Gomoku

keep track of clients connected, init a game every time two clients connect (on an even number)

Closed this issue · 1 comments

For multiple games.

I didn't do it exactly this way, but it works fine. So, it basically just waits for two connections before calling start_subserver, and then start_subserver starts two threads instead of one as it did previously.

The only way a game now starts is if two clients connect

So, it looks something like this
//accept blocks until incoming connection
sockfd[0] = accept(client)

and then right after that
sockfd[1] = accept(client)

Now we have two clients, so we can start the subservers and therefore start a game
subserver(sockfd);

subserver inits a game struct where variables are shared between the two threads, and the game is played.