Having just learned that $-variables, while often considered to be global,
are actually thread-specific.
Therefore, I'd like to create a thread which does input and output from
another file, a socket, or some other similar device. That way, with the
proper protocol wrapper, I could offer all kinds of interactive services
like MUDs and such. No, I don't have inetd; I'm running Windows 98.
I tried just setting them in the following code, and that didn't work.
I wasn't surprised that "TWO" didn't print, but neither did THREE. It
was as if I had broken the socket by assigning them elsewhere. Any
ideas?
class TinyServer
def run
Thread.new {
server = TCPServer.new (2323)
while (socket = server.accept)
print "Caller!\n"
Thread.new {
socket.puts "ONE"
$< = socket
$> = socket
puts "TWO"
socket.puts "THREE"
}
end
}
# command loop
while TRUE
puts "Type QUIT to stop the server."
break if gets.downcase.strip == "quit"
end
end
end
TinyServer.new.run
--
Nick Bensema <nickb / io.com> ICQ#2135445
==== ======= ==============
AVOID MISSING BALL TO SCORE