I've written a small multi-threaded message board server.

I originally tried to use cgi.rb, because I thought that made sense,
but hit problems because it assumes input is from $stdin and output is to
$stdout.  Obviously, since I can have multiple threads running, I
couldn't just assign the socket for a connection to $stdin and $stdout,
since then I'd get intermingled I/O and everything would fall in a heap.

Since I now have a basically functioning system, I thought it would be a
good time to go back and see if I can't work out some way to make cgi.rb
do what I want.

Has anyone else done this kind of thing?  Ie, used the cgi.rb facilities
in a multi-threaded program?

If so, can you give me any pointers on the simplest way to make the code
do all its I/O to a given socket?

TIA