Sha256: e7cd920c40076afd28986809e45fafdc4e6c4cf219947899ff9467ce3a45d21f

Contents?: true

Size: 582 Bytes

Versions: 7

Compression:

Stored size: 582 Bytes

Contents

module RestFtpDaemon
  class Launcher
    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

7 entries across 7 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.302.3 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-0.302.2 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-0.302.1 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-0.302.0 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-0.300.3 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-0.300.2 lib/rest-ftp-daemon/launcher.rb
rest-ftp-daemon-0.300.1 lib/rest-ftp-daemon/launcher.rb