Class: TCPSocket
- Inherits:
-
Object
- Object
- TCPSocket
- Defined in:
- lib/tcp_socket_extension.rb
Class Method Summary collapse
- .listening_service?(options) ⇒ Boolean
- .verbose_wait ⇒ Object
- .wait_for_service(options) ⇒ Object
- .wait_for_service_termination(options) ⇒ Object
Class Method Details
.listening_service?(options) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tcp_socket_extension.rb', line 14 def self.listening_service?() Timeout::timeout([:timeout] || 20) do begin socket = TCPSocket.new([:host], [:port]) socket.close unless socket.nil? true rescue Errno::ECONNREFUSED, Errno::EBADF # Windows false end end end |
.verbose_wait ⇒ Object
27 28 29 30 |
# File 'lib/tcp_socket_extension.rb', line 27 def self.verbose_wait puts ".\n" sleep 2 end |
.wait_for_service(options) ⇒ Object
6 7 8 |
# File 'lib/tcp_socket_extension.rb', line 6 def self.wait_for_service() verbose_wait until listening_service?() end |
.wait_for_service_termination(options) ⇒ Object
10 11 12 |
# File 'lib/tcp_socket_extension.rb', line 10 def self.wait_for_service_termination() verbose_wait while listening_service?() end |