Skip to content

Instantly share code, notes, and snippets.

@betamatt
Created March 26, 2012 17:46
Show Gist options
  • Save betamatt/2207474 to your computer and use it in GitHub Desktop.
Save betamatt/2207474 to your computer and use it in GitHub Desktop.
Blackhole server that accepts connections but never responds.
require 'eventmachine'
module Blackhole
def post_init
puts "CONNECT"
end
def receive_data data
puts "RECEIVE: #{data}"
end
def unbind
puts "DISCONNECT"
end
end
# Note that this will block current thread.
EventMachine.run {
port = ENV['PORT'] || 9000
puts "Starting server on port #{port}"
EventMachine.start_server "127.0.0.1", port, Blackhole
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment