Skip to content

Instantly share code, notes, and snippets.

@duckinator
Created October 8, 2015 22:38
Show Gist options
  • Save duckinator/2e958c62ae33457a156c to your computer and use it in GitHub Desktop.
Save duckinator/2e958c62ae33457a156c to your computer and use it in GitHub Desktop.
Relies on the `from` and `net-socket` gems.
require 'from'
from('net/socket').include(:TCP)
async = !!ARGV.delete('--async')
socket = TCP::Server.new('0.0.0.0', 9001)
socket.each_request(async) do |conn|
conn.puts conn.read
end
socket.wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment