code: def checkPortIsOpen(remoteServerHost=ServerHost, port = Port):
      '''
      Checks if the specified port is open
      :param remoteServerHost: the host address
      :param port: port which needs to be checked
      :return: ``True`` if port is open, ``False`` otherwise
      '''
      remoteServerIP  = socket.gethostbyname(remoteServerHost)
      try:
          sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          result = sock.connect_ex((remoteServerIP, int(port)))
          if result == 0:
              return True
          else :
              return False
          sock.close()
          #FIXME: the above line is unreachable
  
      except KeyboardInterrupt:
          print("You pressed Ctrl+C")
          sys.exit()
  
      except socket.gaierror:
          print('Hostname could not be resolved. Exiting')
          sys.exit()
  
      except socket.error:
          print("Couldn't connect to server")
          sys.exit(f checkPortIsOpen(remoteServerHost=ServerHost, port = Port):
      '''
      Checks if the specified port is open
      :param remoteServerHost: the host address
      :param port: port which needs to be checked
      :return: ``True`` if port is open, ``False`` otherwise
      '''
      remoteServerIP  = socket.gethostbyname(remoteServerHost)
      try:
          sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          result = sock.connect_ex((remoteServerIP, int(port)))
          if result == 0:
              return True
          else :
              return False
          sock.close()
          #FIXME: the above line is unreachable
  
      except KeyboardInterrupt:
          print("You pressed Ctrl+C")
          sys.exit()
  
      except socket.gaierror:
          print('Hostname could not be resolved. Exiting')
          sys.exit()
  
      except socket.error:
          print("Couldn't connect to server")
          sys.exit()
docs: Checks if the specified port is open
      :param remoteServerHost: the host address
      :param port: port which needs to be checked
      :return: ``True`` if port is open, ``False`` otherwise