views:

30

answers:

0

Hello,

The Ruby framework I am using provides a TcpServer class which, surprisingly, establishes a TcpServer. It has two threads - one monitors with Kernel.select the listener thread and dispatches a on_client_connect(fd) method and the other monitors established connections and dspatches on_client_data(fd).

I want to use the TcpServer class, but I need to do some proxying and from OO design perspective it would be better if I'd have a Thread per connection pair (incoming and proxied - outgoing) encapsulated in an object that calls select and acts on it.

Is there a problem with multiple threads calling multiple selects on same fds?