Skip to content

reverseLookup ​

reverseLookup performs a reverse name lookup for an address.

The lookup runs asynchronously and accepts an optional timeout in milliseconds. Network failures fulfill the promise with Err(NetError).

SignaturereverseLookup(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
    }
}

Error Handling ​

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
    }
}

Typical failures include ERR_NET_INVALID_ADDRESS, ERR_NET_RESOLVE, and ERR_NET_TIMEOUT.