From: Drew Olson Date: 2007-02-06T23:45:35+09:00 Subject: Simple Server Question Guys - 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. -Dre2 require 'socket' class ChatServer def initialize(port) @port = port end def run_server @sessions = {} @my_server = TCPServer.new('localhost',@port) puts "Server running...." while(session = @my_server.accept) @action = session.gets puts @action end @my_server.close end end my_server = ChatServer.new((ARGV[0] || 80).to_i) my_server.run_server -- Posted via http://www.ruby-forum.com/.