Created
March 26, 2012 17:46
-
-
Save betamatt/2207474 to your computer and use it in GitHub Desktop.
Blackhole server that accepts connections but never responds.
This file contains 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 '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