From: Drew Olson Date: 2007-02-07T00:24:13+09:00 Subject: Re: Simple Server Question > If you are running Windoze, then I expect it's blocking inside one of > the > socket calls. > > BTW there is a fuller server example, which handles each incoming > connection > in its own thread, at > http://wiki.rubygarden.org/Ruby/page/show/SingletonTutorial > > Search for "Pop3Server" > > HTH, > > B. I am running Windows (at work, mac at home) but I thought ruby's thread were "cross platform" as there were implemented purely in ruby. I even added a thread to handle keyboard input in the on the server and it's still locking on my box. I see the output: Server running... Press any key to quit... But nothing I press unlocks it. Am I doing something wrong here (revised code below)? require 'socket' class ChatServer def initialize(port) @port = port @sessions = {} end def run_server @my_server = TCPServer.new('localhost',@port) Thread.new(self){|server| InputHandler.new(server).run} while(session = @my_server.accept) puts session.gets session.close end end def quit @my_server.close exit end end class InputHandler def initialize(server) @server = server puts "Server running..." end def run puts "Press any key to quit..." gets server.quit end end my_server = ChatServer.new((ARGV[0] || 80).to_i) my_server.run_server -- Posted via http://www.ruby-forum.com/.