def check_port(port):
  """Verifies port value given is valid.

  Args:
      port (int): port number to verify

  Raises:
      ValueError: if port number provided is invalid

  Returns:
      int: port number
  """

  if port < 0 or port > 65535:
    raise ValueError("Port {} out of range".format(port))
  return port