Sha256: 6c076d2220b4bf1f59d0af48eb3e300e4f75bccfe8e5ea5503ec4a3cd65b9f15

Contents?: true

Size: 603 Bytes

Versions: 21

Compression:

Stored size: 603 Bytes

Contents

module RestFtpDaemon
  class Launcher
    # Class constants
    LAUNCHER_PORT_TIMEOUT       = 3
    LAUNCHER_PORT_LOCALHOST     = "127.0.0.1"

    class << self

      def local_port_used? port
        Timeout.timeout(LAUNCHER_PORT_TIMEOUT) do
          begin
            TCPSocket.new(LAUNCHER_PORT_LOCALHOST, port).close
            true
          rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
            false
          rescue Errno::EADDRNOTAVAIL
            "local_port_used: Errno::EADDRNOTAVAIL"
          end
        end
      rescue Timeout::Error
        false
      end

    end

  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rest-ftp-daemon-1.1.1 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.1.0 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.15 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.14 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.13 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.12 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.11 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.10 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.9 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.8 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.7 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.6 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.5 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.4 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.3 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.2 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-1.0.1 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-0.502.2 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-0.502.1 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-0.502.0 lib/rest-ftp-daemon/launcher.rb