--- /dev/null
+#--\r
+#\r
+# Author:: Francis Cianfrocca (gmail: blackhedd)\r
+# Homepage:: http://rubyeventmachine.com\r
+# Date:: 16 July 2006\r
+# \r
+# See EventMachine and EventMachine::Connection for documentation and\r
+# usage examples.\r
+#\r
+#----------------------------------------------------------------------------\r
+#\r
+# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.\r
+# Gmail: blackhedd\r
+# \r
+# This program is free software; you can redistribute it and/or modify\r
+# it under the terms of either: 1) the GNU General Public License\r
+# as published by the Free Software Foundation; either version 2 of the\r
+# License, or (at your option) any later version; or 2) Ruby's License.\r
+# \r
+# See the file COPYING for complete licensing information.\r
+#\r
+#---------------------------------------------------------------------------\r
+#\r
+#\r
+# \r
+\r
+module EventMachine\r
+ module Protocols\r
+\r
+ class TcpConnectTester < Connection # :nodoc:\r
+ include EventMachine::Deferrable\r
+\r
+ def self.test( host, port )\r
+ EventMachine.connect( host, port, self )\r
+ end\r
+\r
+ def post_init\r
+ @start_time = Time.now\r
+ end\r
+\r
+ def connection_completed\r
+ @completed = true\r
+ set_deferred_status :succeeded, (Time.now - @start_time)\r
+ close_connection\r
+ end\r
+\r
+ def unbind\r
+ set_deferred_status :failed, (Time.now - @start_time) unless @completed\r
+ end\r
+ end\r
+\r
+ end\r
+end
\ No newline at end of file