Jakub-

You used TCPSocket in your subject, and TCPServer in your message, but I'll
assume you mean TCPSocket since you're writing a Jabber client library. From
my experience with Ruby, it appears that TCPSocket is thread safe. In fact,
I would assume that most of the included Ruby libraries are, provided you
make sure you know what you're doing. Any race conditions introduced would
probably be introduced by your project, rather than the Ruby core. (I could
be wrong here, but this is my feeling.)

I have done what you asked about with Ruby. Block for input on a thread from
a socket and wrote to it on another thread.

Hope this helps,

Ben

-----Original Message-----
From: Jakub Travnik [mailto:j.travnik / sh.cvut.cz]
Sent: Wednesday, November 14, 2001 12:38 PM
To: ruby-talk / ruby-lang.org
Subject: [ruby-talk:25211] Is TCPSocket thread safe?


Hello,
  Does anybody know if TCPServer is thread safe?
I want one thread to do blocking read and other
occasionally write. (it is for my jabber client library)

And one more general question, how to determine
thread safeness for other objects from default
ruby libraries?

Jakub Travnik
jabber://jtra / jabber.com
ICQ: 66770334 (deprecated)