def validipport(port):
 try:
  if (not (0 <= int(port) <= 65535)):
   return False
 except ValueError:
  return False
 return True

def validipport ( port ) : try : if ( not ( 0 <= int ( port ) <= 65535 ) ) : return False except ValueError : return False return True
returns true if port is a valid ipv4 port .