Hi,

From: "Brian Schröäer" <ruby / brian-schroeder.de>

> in the program only one thread at a time is reading, and only one at a
> time is writing. I wanted to know if I could read and write to the same
> socket from two different threads simultaneously. And I think this is a
> subset of the answer, so I take it for "yes".

I didn't know if two threads simultaneously accessing the same
socket was legal, (I think I asked about this here a year or
two ago) .. so I'm doing a $sock.dup, the read-thread using one
and the write-thread using the other.  I don't know if the
#dup is necessary or beneficial, actually.  But for what it's
worth, here's how I'm using it:

http://bwk.homeip.net/ftp/dorkbuster/wallfly/buffered-io.rb

The above is an IO class whose read thread just slurps data
as fast as it can in the background.  And whose write thread
writes data out, similarly, when it can.  So the code interfacing
with this class gets a non-blocking read & write, with infinite
buffer size.  (Up to available RAM of course.)  For my purposes
it has been convenient... dunno if it would be useful to anyone
else.  If so I could put it on RAA (?)

It's been stress tested with as many variations of reads, writes,
random & non random timing delays as I could think of to devise,
running for days under these stress conditions without a hiccup.
I realize that doesn't prove anything, but I have a good feeling
about its reliability at this point.

For what it's worth :)

Regards,

Bill