Skip to content

Instantly share code, notes, and snippets.

@cmhobbs
Created August 20, 2010 21:38
Show Gist options
  • Save cmhobbs/541250 to your computer and use it in GitHub Desktop.
Save cmhobbs/541250 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'eventmachine'
module EchoServer
def post_init
puts "-- CONNECTION ESTABLISHED"
end
def receive_data data
send_data "-- DATA RECEIVED"
filename = data.split('>')[0]
filedata = data.split('>')[1]
puts "-- INCOMING DATA"
puts "-- FILENAME: #{filename}"
puts "-- DATA:\n\n #{filedata}"
puts "\n-- END DATA"
end
def unbind
puts "-- CONNECTION TERMINATED"
end
end
EventMachine::run {
EventMachine::start_server 'YOUR_SERVER_HERE', 7799, EchoServer
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment