-
-
Save hinrik/1250865 to your computer and use it in GitHub Desktop.
Cool.io echo server using the fancy new DSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'cool.io' | |
ADDR = 'localhost' | |
PORT = 4321 | |
cool.io.server ADDR, PORT do | |
on_connect do | |
puts "#{remote_addr}:#{remote_port} connected" | |
end | |
on_close do | |
puts "#{remote_addr}:#{remote_port} disconnected" | |
end | |
on_read do |data| | |
write data | |
end | |
end | |
puts "Echo server listening on #{ADDR}:#{PORT}" | |
cool.io.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment