require "al_worker_tcp" class WebServer < AlWorker::Tcp def start_service( sock ) req = [] while txt = sock.gets txt.chomp! break if txt.empty? req << txt end if !req.empty? && req[0].upcase.start_with?("GET ") sock.puts "HTTP/1.0 200 OK\r\n" sock.puts "Content-Type: text/html\r\n" sock.puts "\r\n" sock.puts "\r\n" sock.puts "TESTPAGE\r\n" sock.puts "

It works!

\r\n" end end end class TcpServer < AlWorker def initialize2() log.level = Logger::DEBUG @tcp = WebServer.new("", 3000) # リスンアドレス、ポート番号を指定。 @tcp.run( self ) end end server = TcpServer.new("web_server") server.daemon()