Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

21 lines (17 sloc) 0.352 kb
# socket example - server side using thread
# usage: ruby tsvr.rb
require "socket"
gs = TCPserver.open(0)
addr = gs.addr
addr.shift
printf("server is on %s\n", addr.join(":"))
loop do
Thread.start(gs.accept) do |s|
print(s, " is accepted\n")
while line = s.gets
s.write(line)
end
print(s, " is gone\n")
s.close
end
end
Jump to Line
Something went wrong with that request. Please try again.