TCPSocket & Threads

Is there any reason ruby’s TCPSocket should not work with threads?
Ie. reading and writing to the same socket in parallel?

I am having some problems, but it could be my code rather than the library :slight_smile:

Where is the best documentation for this module?

The pragmatic book
http://www.rubycentral.com/book/lib_network.html
seems to leave out many details

  • E.g. TCPSocket sessions have “read” and “write” methods which are not mentioned.
  • The send method seems to take two arguments instead of just one
    send(msg, length)

Is this code documented elsewhere? The only other place I know where to
look is the Ruby-1.8.0/ext/socket/socket.c file…that can’t be right?!

Jesper

* E.g. TCPSocket sessions have "read" and "write" methods which are not
mentioned.

svg% ruby -rsocket -e 'p TCPSocket.ancestors'
[TCPSocket, IPSocket, BasicSocket, IO, File::Constants, Enumerable, Object, Kernel]
svg%

TCPSocket inherit from IO, this why it has #read, #write

* The send method seems to take two arguments instead of just one
  send(msg, length)

this is

     def send(msg, flags, to = nil)
     end

Guy Decoux