From: Brian Candler Date: 2007-02-07T00:05:24+09:00 Subject: Re: Simple Server Question On Tue, Feb 06, 2007 at 11:45:35PM +0900, Drew Olson wrote: > I'm working on a simple Chat Server/Client just to become familiar with > ruby socket programming. I've put together this very simple server that > accepts a connect and prints out the first message received. I've done > this in Java as well, but the issue I'm finding here is I cannot ctrl+c > to quit the server. Do I need to create a thread to listen for keyboard > input and then pass this to a quit method? It seems to me that ctrl+c > (or ctrl+z depending on os) should always force quite a running program, > right? In this case, it's just hanging. Any help appreciated. You didn't say what platform you're running on. It works for me, using Linux (Ubuntu 6.06): $ ruby1.8 ert.rb 9999 Server running.... flurble << this sent from a client ert.rb:16:in `accept': Interrupt from ert.rb:16:in `run_server' from ert.rb:27 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.