Skip to content

Instantly share code, notes, and snippets.

@JakubOboza
Created October 3, 2011 18:05
Show Gist options
  • Save JakubOboza/1259790 to your computer and use it in GitHub Desktop.
Save JakubOboza/1259790 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
['rubygems', 'eventmachine'].map{|x| require x}
module SelfServer; def receive_data(data); send_data(IO.readlines __FILE__); end; end;
EventMachine::run do
host = ARGV[1] || '0.0.0.0'
port = ARGV[2] || 8080
EventMachine::start_server host, port, SelfServer
puts "If you don't like defaults try chaging host or port"
puts "Open 2 terminal and try telnet #{host} #{port} and press enter"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment