Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env ruby

require 'rubygems'
require 'eventmachine'

module EchoServer
  def receive_data(data)
    send_data(data)
    close_connection
    puts "%.4f" % [(Time.now.to_f-$time)*1000]
    $time = Time.now.to_f
  end
end

$time = Time.now.to_f
GC.disable
EM.epoll
EventMachine::run do
  host = '0.0.0.0'
  port = 8001
  EventMachine::start_server host, port, EchoServer
end