Advertisement

Networking Design

Started by March 02, 2005 06:16 AM
0 comments, last by Gorax 19 years, 11 months ago
Here is my current structure: Client - ClientIO ----------------------------------------- Server - ServerIO (THREAD)-----------------------------------------------------(THREAD) Client is the main game class, with the game loop in it. Client IO is a thread which is listening for input, and can also write. Server is the server lol server io is a thread assigned for each connection to listen and to write. Clients send information every loop of the game, everyLoop the update method is called in the Client IO and it sends the Server the new X, Y Co-ordinates etc. Is this an efficient way of doing this? Or will it cause problems? Thanks in advance, Nick
You could probably get a reasonable result if you used 2 threads per server/client. The main thread would only handle data that's going to be sent, along with your updates, etc., and the other thread will continually read data and handle events based upon the data received.

If you plan on making a simple application/game (like a game of Chess) where TCP sockets wouldn't cause problems, you could use those. On the other hand, if you plan on making something that requires a near-continual stream of data, or data to be sent to numerous clients (like in a FPS/MORPG), you'll need to use UDP sockets, or the connection could be bogged down very quickly (if packets need to be resent). This also means you'll need a way to ensure that the data received is infact the data that was sent, and that it was sent/received from the correct client(s)/server.

This *should* be a reasonable way to go about it, but if anybody wants to correct me, feel free to do so.

This topic is closed to new replies.

Advertisement