So I'm trying to create a simple text input Texas Hold 'Em game that can be played in a Terminal between multiple computer. (Disturbing lack of hold 'em games that don't require Facebook integration or a million ads or micro transactions :c )
With my current knowledge I can create the TCP Server and Connect some clients, but I'm not sure how to proceed from here. How can I communicate between the clients and server turn by turn using text input effectively? My vague idea of what to do is
- Accept clients, store FD in Array
- Loop through Id's sending them 2 cards each
- Create thread with a game info struct, that reads users text input
- Wait for thread to finish and return value will be the players move
- Update game info, and move repeat step 3-4 for all Clients
- Break whenever only 1 player is left, or all bettings phases are over then repeat
This outline makes sense in the server, but I'm not sure how to construct the client to not do anything until it gets prompted by the thread creation in the main server while loop. If anyone has any advice or links to helpful articles or example code I would really appreciate it thanks so much!!