Skip to content

Instantly share code, notes, and snippets.

@rhenium
Created April 19, 2015 04:40
Show Gist options
  • Save rhenium/48aeae2049feb746f210 to your computer and use it in GitHub Desktop.
Save rhenium/48aeae2049feb746f210 to your computer and use it in GitHub Desktop.
$port = 10000
require "socket"
server = TCPServer.open($port)
loop do
Thread.start(server.accept) do |cli|
puts "connected: " + cli.__id__.to_s
while line = cli.gets
puts cli.__id__.to_s + ": " + line.chomp
end
cli.close
puts "disconnected: " + cli.__id__.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment