Thread Client/Server

Advanced game related topics
Nelligan
User
User
Posts: 13
Joined: Sat May 10, 2003 6:04 am

Thread Client/Server

Post by Nelligan »

Hi,

I chose to go for a threaded client/server topology for a small mmorpg project. Not a thread per client though but one to receive, one to send and the main prog for the rest. It's like the post office model.

The way I see it is this:
- I check events in main loop and put them in variables that the treads look into
- The receive thread puts the received data in a memory buffer
- The main loop parse the data, detect what is needed and fills the send memory buffer accordingly. and set a send flag
-The send thread sends the data on the network

Now I thought I could use linked lists in the receive thread to put the one or more requests in it and do the same when passing the data from the main loop to the send thread. But I'm not sure I can lock a structure or linkedlist with the thread syncing library.

So I wonder what would be a good way to pass the data between the threads and the main prog. I want to minimize the parsing of the data so all of it happens in the main loop. I also want to know if a variable can be read from 2 threads at the same time or if I have to sync the reads also.

I write this in a hurry so sorry if it's unclear. I will correct it if it's the case. Feel free to suggest anything, but if it is to stop using threads, please suggest another way also.


Thank you very much