delegateResolve

Given an address and a port, resolves these and populates the array of unique Address IPs inside the passed Connection.

@safe @system
delegateResolve
(,
const string address
,
const ushort port
,
const bool useIPv6
,
scope void delegate onSuccessDg
,
scope void delegate onRetryDg
,
scope bool delegate onFailureDg
,
const bool* abort
)

Parameters

conn Connection
address string

String address to look up.

port ushort

Remote port build into the Address.

useIPv6 bool

Whether to include resolved IPv6 addresses or not.

onSuccessDg void delegate

Delegate to call on successful resolution.

onRetryDg void delegate

Delegate to call on recoverable resolution failure.

onFailureDg bool delegate

Delegate to call on potentially unrecoverable resolution failure. (The return value dictates whether to retry or not.)

abort bool*

Pointer to the global abort flag, which -- if set -- should make the function return.

Examples

Connection conn;

void onSuccessDg(ResolveAttempt attempt)
{
    writeln("Resolved IPs: ", conn.ips);
}

void onRetryDg(ResolveAttempt attempt)
{
    writeln("Retrying...");
}

bool onFailureDg(ResolveAttempt attempt)
{
    writeln("Failed to resolve!");
    return false;
}

immutable actionAfterResolve = delegateResolve(
    conn: conn,
    address: "example.com",
    port: 80,
    useIPv6: true,
    onSuccessDg: &onSuccessDg,
    onRetryDg: &onRetryDg,
    onFailureDg: &onFailureDg,
    abort: abort);