Skip to content

reverseLookup ​

reverseLookup realiza una resolución inversa de nombre para una dirección.

La búsqueda es asíncrona y acepta un timeout opcional en milisegundos. Los fallos de red cumplen la promesa con Err(NetError).

FirmareverseLookup(address: string, timeoutMs?: u64): Promise<Result<string, NetError>>
tyrus
import { NetError, reverseLookup } from "tyrus:net";

async function lookup(): Promise<void> {
    const result: Result<string, NetError> = await reverseLookup("127.0.0.1", 1000);
    match (result) {
        Ok(name) => { print(name); } // localhost
        Err(error) => { printError(error.code); } // ERR_NET_REVERSE_LOOKUP
    }
}

Manejo de errores ​

error

tyrus
import { NetError, reverseLookup } from "tyrus:net";

async function lookup(): Promise<void> {
    const result: Result<string, NetError> = await reverseLookup("not-an-address", 1000);
    match (result) {
        Ok(_) => {}
        Err(error) => { printError(error.code); } // ERR_NET_INVALID_ADDRESS
    }
}

Los fallos habituales incluyen ERR_NET_INVALID_ADDRESS, ERR_NET_RESOLVE y ERR_NET_TIMEOUT.