server.rb
rbmud-0.2/lib/server.rb · 582 B
From the archive RbMUD-0.2.tar.bz2
Download the archive « Back to the archive contents
#!/usr/bin/env ruby
# $Revision: 1.2 $
# $Date: 2003/12/04 22:18:34 $
# $Author: jefus, mikeman2 $
require "socket"
class Server
attr_accessor :socket, :connections
def initialize(port = 4000)
@connections = []
@socket = TCPServer.open(port)
Logger.log("Waiting for connections on port #{port}.")
Thread.abort_on_exception = true
Thread.new do
while true
begin
conn = Connection.new(@socket.accept)
@connections << conn
rescue
Logger.log("Uberdeath to #{conn}! #{$!}")
end
end
end
end
end
Logger.log("Server code initialized.")