|
From: | Nicolas Hognon |
Subject: | Re: [Nel] NeL Network Engine |
Date: | Wed, 28 Feb 2001 10:57:11 +0100 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; 0.8) Gecko/20010215 |
In this case, we have to forget the solution where each socket is on a thread and use a blocked receive(). The problem is that select() is quite slow and if we have only 100 thread, each thread needs to manage, with a select(), around 50 players and we ll lost lot of time to create the array for the select() and check who have wakeup the select().
I encouter the same problem : one thread must manage more than one socket on the server. the problem is how managing those socket
in the thread. the problem is I want to be portable between windows and linux :(( under windows there is many solution : - select (the only one which is portable) - windows event and message - overlapped I/O under linux the only solution I know is : - select / poll : i'm not sure but i think the difference between select and poll is that with poll you don't have to fill your array before each call. another problem when a thread maange more than one socket is what your threads will do : a first approch is something like that : while(run) { TestSokets(); for each socket which received something do read the incoming data process the data send data done } but during one step of this loop your socket list must be locked so if a new socket need to enter this thread the calling thread will be blocked. a solution is to have more than one thread type. thread which test and read socket (perhaps wire in socket to) thread which to process a network message queue. (and perhaps thread which send network message) but it increase the number of thread so the maximum number of client is lesser. but i'm not really used to programming with thread yet so perhaps my problem are not really problems. i hope this can help and you can understand me :)) and i think i'll take a look at http://oss.sgi.com/projects/state-threads/ to ... good luck -- Nicolas Hognon address@hidden Virtools - The Behavior Company Tel. (+33) 1 42 71 46 86 / Fax. (+33) 1 42 71 86 53 http://www.virtools.com/
[Prev in Thread] | Current Thread | [Next in Thread] |