Skip to content

Instantly share code, notes, and snippets.

@brixen
Created January 18, 2011 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brixen/784801 to your computer and use it in GitHub Desktop.
Save brixen/784801 to your computer and use it in GitHub Desktop.
require 'socket'
def say(*args)
STDOUT.puts *args
STDOUT.flush
end
Thread.abort_on_exception = true
s1 = TCPServer.new("127.0.0.1", 9000)
say "Before s1#accept"
s1_t = Thread.new do
begin
s1.accept
rescue Exception => err
say "s1#accept raised #{err.inspect}"
end
end
say "After s1#accept thread block"
say "Sleeping for 10 seconds"
sleep 10
say "Closing s1"
s1.close
say "Waiting for s1 thread to join()"
s1_t.join
say "s1 thread joined"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment