From: Greg Millam Date: 2004-07-29T23:07:53+09:00 Subject: Re: IO issues: forking, select, and duplexing Hal Fulton wrote: >> If your IO-like object contains a reference to a real IO object that >> can be a target of select, you can call select on the IO-like object >> by just adding "to_io" method that returns real IO object. > > That is very interesting. I don't think I can do this easily (as the > code is from a third party), but I'll look at it. > >> |So I thought: Well, I'll fork a TCPServer. >> >> If you really need full duplex IO object using fork, how about using >> "open" instead of TCPServer: >> >> open("|-", "w+") do >> # the code to copy from STDIN to IO-like >> # and from IO-like to STDOUT >> end May I suggest Socket.pair ? sockets = Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM, 0) sockets[0].puts "hello" sockets[1].gets #=> "hello\n" - Greg Millam