[MUD-Dev] Multithreaded servers using objects

David Loeser daklozar at home.com
Mon May 14 22:22:55 CEST 2001


> -----Original Message-----
> From: mud-dev-admin at kanga.nu [mailto:mud-dev-admin at kanga.nu]On Behalf Of
> Chambers
> Sent: Monday, May 14, 2001 1:46 PM
> To: mud-dev at kanga.nu
> Subject: [MUD-Dev] Multithreaded servers using objects

> The basic way a server works is create a thread, wait for a
> connection, accept connection and create new listener, then do the

Here's how my servers that spawn worker threads work:

  1) Create listener socket.
  2) Listener accepts new connects and spawns new thread.
  
Only one listener socket is created (well, you can have more than one
but that is another scenario) for the server.

> connection.  Most of the time this is done through a global
> function.  Is it possible, to instead do all your threading within
> member functions?  I.E write one server class that does the spin-off
> threads from it's private functions/data ?

Yes, it is possible to do your threading within member functions. I
can send you an example of how to do this if you would like.

I suggest you not spin off multiple threads of the server class. This
isn't very scalable and multiple threads on a single processor can be
problematic.  Essentially, with too many threads, the task switching
at the OS level would be enough to 'kill' the server.

I think there is another thread discussing the use of I/O completion
ports that may interest you. There are also knowledge base articles on
the MSDN site.

Dave "Dak Lozar" Loeser

_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list