Created
February 10, 2012 05:34
-
-
Save fetep/1786956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require "socket" | |
1000.times do |n| | |
puts "opening socket ##{n}" | |
TCPSocket.new("client4.scl2.svc.mozilla.com", 4444) | |
end | |
$stdin.read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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