• Advertisement
Sign in to follow this  

Networking Design

This topic is 4738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement