A question about threads

What do I need to do to make the following code write the input from
each thread to all other active threads? I can’t figure out how to
access the list of threads in GServer.

#Begin Test Server

require ‘GServer’

class TestServer < GServer
def initialize(port=4000, *args)
super(port, *args)
end #end initialize
def serve(io)
client_info = Hash.new #Hash to contain connected client
information.
input = io.gets.strip #Input from client, stripped to
remove newline.
client_info[‘name’] = input
loop do
str = io.gets
io.write("#{client_info[‘name’]}: #{str}")
end #end loop
end #end serve
end #end TestServer

server = TestServer.new
server.audit = true
server.start
server.join

Chris B. wrote:

What do I need to do to make the following code write the input from
each thread to all other active threads? I can’t figure out how to
access the list of threads in GServer.

You could keep a hash of connected clients (managed with
TestServer#connected and TestServer#disconnected) and stow some
information away in there, polling for it in your loop.

-Ben