OSDN Git Service

Replaced mongrel with thin
[redminele/redminele.git] / ruby / lib / ruby / gems / 1.8 / gems / eventmachine-0.12.10-x86-mswin32-60 / lib / em / protocols / tcptest.rb
diff --git a/ruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.10-x86-mswin32-60/lib/em/protocols/tcptest.rb b/ruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.10-x86-mswin32-60/lib/em/protocols/tcptest.rb
new file mode 100644 (file)
index 0000000..df776dd
--- /dev/null
@@ -0,0 +1,53 @@
+#--\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