lib/latexml.rb
def local_port_open?(port, seconds=1)
    Timeout::timeout(seconds) do
      begin
        TCPSocket.new('localhost', port).close
        true
      rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
        false
      end
    end
  rescue Timeout::Error
    false
  end
# One way of checking if we have a socket server running at a given port
One way of checking if we have a socket server running at a given port
One way of checking if we have a socket server running at a given port
def local_port_open?(port, seconds=1)
    Timeout::timeout(seconds) do
      begin
        TCPSocket.new('localhost', port).close
        true
      rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
        false
      end
    end
  rescue Timeout::Error
    false
  end
def local_port_open? ( port , seconds = 1 ) Timeout :: timeout ( seconds ) do begin TCPSocket . new ( 'localhost' , port ) . close true rescue Errno :: ECONNREFUSED , Errno :: EHOSTUNREACH false end end rescue Timeout :: Error false end
One way of checking if we have a socket server running at a given port
One way of checking if we have a socket server running at a given port
port
seconds