Skip to content

Instantly share code, notes, and snippets.

@tarcieri
Created November 20, 2010 07:19
Show Gist options
  • Save tarcieri/707684 to your computer and use it in GitHub Desktop.
Save tarcieri/707684 to your computer and use it in GitHub Desktop.
Cool.io echo server using the fancy new DSL
require 'rubygems'
require 'cool.io'
cool.io.server 'localhost', 4321 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