   Designing Client-Server Games
  Ok so I think I'm in a good place now for understanding TCP, UDP and multithreading I'm looking to put it all together. I have seen a design in the book:Core Techniques and Algorithms in Game Programming by Daniel Sánchez-Crespo Dalmauand he describes a design as follows:Quote:Server, step 1: Create socket, and bind to IP and port.Server, step 2: Listen, and wait in an accept call. Open "game lobby" and show IP/port.Server, step 3: Now the server is awaiting connections. Two threads/processes are required: an interface thread running the game menu interaction and another running the accept call so the system does not lock.Client, steps 1 to N: Open socket, and connect to the game server.Server, step 4: Update screen for each accepted connection. Implement the desired connection policy (connectionless iterative, connection-oriented concurrent).Server, steps N+1: At this point, all the clients are connected to the server. When the game menu interaction thread indicates a player has started the game, you can effectively close the main server socket, interrupt the accept call, and start the game with the connection sockets. The game server thus shuts down and accepts no further connections. This has confused me a little in several places. Step 2 and 3 seem to contradict themselves. The way I understand, its saying accept a first client then create a lobby, then in step 3 it says create a thread/process for accepting clients and another for interface.The way I thought this system worked was to enter a loop accepting clients and creating a new thread/ process for each.Could someone shed some light on this confusion for me. Thank you!   
  If that is the literal text from the game book, then the book sounds like it's garbage. You are correct; you only listen() in step 2 for the server.Btw: you don't need two threads. If you select() on the listening socket, it will tell you whether you can accept() without blocking or not. You can do this (polling) in a WM_TIMER loop, every 50 milliseconds or so, for small-scale game servers, and it will work fine.;  Thanks for the help, and unfortunately that was the actual text!   