From: Robert Klemme Date: 2009-06-10T21:06:43+09:00 Subject: Re: inheriting socket in child process on Windows 2009/6/10 : > In my Ruby application, I accept TCP connections from several clients. > When > any client sends a particular command, I want to spawn a child process > in > place of the parent process that will continue to service the already- > open > TCP connections without the clients needing to reconnect. > > I originally wrote this code on Linux, and it works in the most > obvious way: > > When the command is received, make note of all of the client's file > descriptors (IO#fileno). Spawn the child process and communicate the > list of > file descriptors to it. In the child process, call TCPSocket.for_fd > for each > file descriptor, and it is ready to read and write data. I would find this more obvious: server = TCPServer.new port while ( client = server.accept ) printf "Got client %p\n", client.peeraddr fork do client.each do |line| client.printf "ECHO: %p\n", line client.flush end client.close_write end client.close end > Is there an entirely different > approach I should be taking? I do not know whether you _should_ take this approach but using cygwin might ease your pain considerably. The approach noted above does work on cygwin. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/