Sha256: 52ff249dbd755b6d70afff3080ee1920daebbf235d54d1d72f8101d2dda88c7a
Contents?: true
Size: 449 Bytes
Versions: 129
Compression:
Stored size: 449 Bytes
Contents
#!/usr/bin/env ruby require 'rubygems' # or use Bundler.setup require 'eventmachine' class EchoServer < EM::Connection def receive_data(data) if data.strip =~ /exit$/i EventMachine.stop else send_data(data) end end end EventMachine.run do # hit Control + C to stop Signal.trap("INT") { EventMachine.stop } Signal.trap("TERM") { EventMachine.stop } EventMachine.start_server("0.0.0.0", 10000, EchoServer) end
Version data entries
129 entries across 126 versions & 10 rubygems