From: Wejn Date: 2002-11-06T01:25:31+09:00 Subject: Re: UDPSocket - bidirectional communication through one socket? > Well, probably UDP is not the best ... Well, for my project UDP is just one of the transports. BTW, TCP on *fast* networks scales really *bad*. It's congestion avoidance/control algorithms aren't good for the "slow ends, fast core" networks. My goal is to write first (test only) implementation of the protocol stack for active routers - and it must have UDP as one of its transports (at the end it would have to be completely protocol independent, but that's another story). > How do you use ::select ? u = UDPSocket.new u.bind('0.0.0.0', ARGV[0]) # part of thread1 (reader): loop do s = select([u], nil, nil, 0.01) next if s.nil? or s[0].size.zero? x = u.recvfrom(65535) # ... processing here end # ... and here comes the rest - second thread2 (writer), ... > Well ... that's great ... but I need to use just one host:port pair for each endpoint and that's (imho) the problem. I'm unable to use 'u' from the example above to simultaneously reading from/writing to network. :( If there's no possibility to use it in the way: host1:X <---------------------> host2:X i'll have to use the (bad) model: host1:X ----------------------> host2:Y host1:Y <---------------------- host2:X but I'm still trying to avoid that, if possible. W. -- Wejn (svamberk.net's Linux section, fi.muni.cz student, linuxfan) >>> Bored? Want hours of entertainment? <<< >>> Just set the initdefault to 6! <<<