def isportopen(host, port):
 if (not (1 <= int(port) <= 65535)):
  return False
 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 out = sock.connect_ex((sanitize_host(host), int(port)))
 return out

def isportopen ( host , port ) : if ( not ( 1 <= int ( port ) <= 65535 ) ) : return False sock = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) out = sock . connect_ex ( ( sanitize_host ( host ) , int ( port ) ) ) return out
return status of a port .