Created
December 24, 2014 15:35
-
-
Save bascht/e182d12b77cc34a2a0d9 to your computer and use it in GitHub Desktop.
Xmas Song
This file contains hidden or 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 'socket' | |
| begin | |
| PAYLOAD=open("xmas.txt").read | |
| SONG=open('silent.txt').read | |
| rescue Exception => e | |
| puts "Burp: #{e}" | |
| exit(-1) | |
| end | |
| server = TCPServer.open(2300) | |
| loop do | |
| Thread.start(server.accept) do |client| | |
| client.puts(PAYLOAD) | |
| SONG.each_line do |line| | |
| client.puts line | |
| sleep 3 | |
| end | |
| client.puts "This christmas message was brought to you by Ruby #{RUBY_VERSION}. Bye!" | |
| client.close | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment