From: Dominik Werder Date: 2003-05-16T22:26:59+09:00 Subject: Re: TCP Sockets > That would mean mixing the binary streams in a non-deterministic way, > which > I think you need to understand the message boundaries within a stream for > this sort of multiplexing to be useful. Of course I'll take some data from Stream "1" and create a packet like this: "Here we go with xx bytes from stream 1" and send this through my "tunnel"-connection. The problem: My program does not know about the underlaying protocol of the stream. So if I receive 99 bytes from that stream, and these 99 bytes are a request of any protocol and my task is to only forward this packet through the tunnel, then I can hardly wait for, say, 100 bytes are available because I did a read(100) and my process blocks until 100 bytes are available :) Sorry for my english, was not the best at school :) > That's fine, your thread can hang as long as you like, and you can > protect > it with a timeout: try > > require 'timeout' > timeout(5) do > sleep 10 > end Thanks, I'll dig into this :) >> How do for example P2P clients do that? One thread per connection? > I don't know what you mean by 'P2P', but a server talking to multiple > clients would indeed normally have a separate thread per client. There's > an > example of a fake pop3 server at > http://www.rubygarden.org/ruby?SingletonTutorial > (at the end of section 2) I mean peer-to-peer, like filesharing clients. They got many concurrently connections.. thanks! Dominik