class Crossover::Server

Public Class Methods

new(port, host='127.0.0.1', max_connections = 10, stdlog = $stdout, audit = true, debug = false ) click to toggle source
Calls superclass method
# File lib/crossover/server.rb, line 15
def initialize(port, host='127.0.0.1', max_connections = 10, stdlog = $stdout, audit = true, debug = false  )
  if stdlog != $stdout
    @logger = Logger.new(File.expand_path(stdlog) )
  end
  super(port, host, max_connections, $stdout, audit, debug )
end

Public Instance Methods

log(message) click to toggle source
# File lib/crossover/server.rb, line 34
def log message
  if @stdlog
    @stdlog.puts("[#{Time.new.ctime}] %s" % message)
    @stdlog.flush
  end

  if @logger
    @logger.info message
  end
end
serve(io) click to toggle source
# File lib/crossover/server.rb, line 22
def serve(io)
  data = io.read(1024)
  log "client:#{io.peeraddr[1]} #{io.peeraddr[2]}<#{io.peeraddr[3]}> post #{data.bytesize} bytes\n#{data}"
  puts ""
  io.puts('Bye!')
end
stopping() click to toggle source
# File lib/crossover/server.rb, line 29
def stopping
  log("#{self.class.to_s} #{@host}:#{@port} stop")
  @logger.close
end