On Sun, Jul 20, 2003 at 01:21:51PM +0900, Pablo Lorenzzoni wrote:
> Hello ALL!
> 
> Is there anyway to pipe two sockets? I want to forward everything that comes 
> from socket1 to socket2 and vice-versa...

Here's how I did it in [63989]:

# s and out are two sockets
loop do
  ready = select [s, out]
  ready = ready[0]
  ready.each do |x|
    case x
    when s
      data = s.sysread(512)
      out.syswrite data
    when out
      data = out.sysread(512)
      s.syswrite data
    end
  end
end

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

(It is an old Debian tradition to leave at least twice a year ...)
	-- Sven Rudolph