Hello. I am attempting to write a multiplayer game using C++ and the WinSock API. The game needs to be able to accept connections then read incoming requests, perform operations and write data back to the client. When the client does not respond for a certain amount of time or it wilfully disconnects, I need to be able to close the connection to the client.
Here is how I propose to handle this:
The server has a thread that waits for connections to be attempted; if the connection is successful, it puts the computer ID (or whatever) in an array. Then I have another thread that gets the port numbers and spawns a new thread for each of them (if there is not one already in existence). Each of the threads waits for commands and writes information back to the client. The thread that accepted connections and the thread that spawns new threads would have to be mutexable, correct?
I am not quite sure how to design this program, so any advice on the design would be helpful. My other problem (the reason that I posted this on the C++ forum XD) is this: I don't know how to properly create a thread or manipulate a thread at all. I have created threads briefly in Java, but from what I hear, C++ threads are quite different, correct?
Any suggestions, sample code, or links to a site with informaiton on the subject are appreciated :)
Thank you,
-wyrmmage