Skip to content

Instantly share code, notes, and snippets.

@phiggins
Created December 6, 2010 17:26
Show Gist options
  • Save phiggins/730607 to your computer and use it in GitHub Desktop.
Save phiggins/730607 to your computer and use it in GitHub Desktop.
pending_connect_timeout
require 'eventmachine'
start, finish = nil
timeout_handler = Module.new do
define_method :unbind do
finish = Time.now
EM.stop
end
end
EM.run {
EM.heartbeat_interval = 0.1
start = Time.now
c = EM.connect("1.2.3.4", 54321, timeout_handler)
c.pending_connect_timeout = 0.2
}
puts finish - start
# linux
# $ ruby -Ilib test_pending_connect_timeout.rb
# 0.2012618
# winxp
# >ruby -Ilib test_pending_connect_timeout.rb
# 20.96875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment