Skip to content

Instantly share code, notes, and snippets.

@fetep
Created February 10, 2012 05:34
Show Gist options
  • Save fetep/1786956 to your computer and use it in GitHub Desktop.
Save fetep/1786956 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require "socket"
1000.times do |n|
puts "opening socket ##{n}"
TCPSocket.new("client4.scl2.svc.mozilla.com", 4444)
end
$stdin.read
#!/usr/bin/ruby
# sudo sh -c 'ulimit -n 100000; ./server.rb'
require "rubygems"
require "eventmachine"
module Server
@@count = 0
@@count_mutex = Mutex.new
def post_init
@@count_mutex.synchronize { @@count += 1 }
puts "connect! count=#{@@count}"
end
def unbind
@@count_mutex.synchronize { @@count -= 1 }
puts "disconnect! count=#{@@count}"
end
end
EM.epoll = true
EventMachine::run do
EventMachine::start_server "0.0.0.0", 4444, Server
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment