So in an event-driven server, how do you ...

clawrenc at clawrenc at
Thu Apr 10 14:29:07 New Zealand Standard Time 1997

In <199704071758.RAA543716 at>, on 04/07/97 
   at 01:39 PM, Michael Hohensee <michael at> said:

>It looks like you guys hate polling.  (Not that I blame you, I don't 
>really like it myself. :)  But if you've got a system that just sits 
>until the next "ripening", how do you do your IO with players?  Do
>you  use an endless loop to poll the connections?  Or do you use the
>SIGIO  signal?  

Rather than re-state, from an earlier post of mine:

> I am particularly interested in how your pool of threads manages socket
> connections.  Are these threads dynamically created to manage connections?
> That is, do you n+1 threads managing your connections, where n is active
> connections plus one to handle connection requests on the master socket?
> Are sockets blocked or do you use some other method of activating threads?

This is really really crude, as its very long time since I looked at
this code:

  One thread watches the master socket and spawns connection sockets
  from there as they come in.

  The child sockets then go into a pool (actually I think its a bag?)
  a monitoring thread.  Any IO to or from a socket is then assigned on
  first available basis to a thread from a waiting pool of IO threads.

  Should an IO request come in which does not have a waiting thread
  to execute it, a new thread is created to process the IO.

  Should the number of IO threads significantly exceed the number of
  sockets, then IO threads are killed down to a base minimum.

  As such the total number of IO threads is proportional to the
  maximum rate of IO transactions thru the system.

I could be way off here, but I think the above is fairly accurate,
well sorta, maybe.

>I tried to use both.  I poll for new commands from the players, and
>use  the SIGIO signal to hook up a new connection.  More than a
>little bit  dirty.  It doesn't work under BSD, then I have to poll
>for everything.

Look into the select() and poll() calls for *nix work.

J C Lawrence                           Internet: claw at
(Contractor)                           Internet: coder at
---------------(*)               Internet: clawrenc at
...Honorary Member Clan McFUD -- Teamer's Avenging Monolith...

More information about the MUD-Dev mailing list