resolveFiber

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

@safe @system
void
resolveFiber
(,
const string address
,
const ushort port
,
const bool useIPv6
,
ref bool abort
)

Parameters

conn Connection

Reference to the current 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.

abort bool

Reference "abort" flag, which -- if set -- should make the function return and the Fiber terminate.

Examples

import std.concurrency : Generator;

Connection conn;
conn.reset();

auto resolver = new Generator!ResolveAttempt(() =>
    resolveFiber(conn, "irc.libera.chat", 6667, false, 10, abort));

resolver.call();

resolveloop:
foreach (const attempt; resolver)
{
    // attempt is a yielded `ResolveAttempt`

    with (ResolveAttempt.State)
    final switch (attempt.state)
    {
    case preresolve:
        assert(0, "shouldn't happen");

    case success:
        // Address was resolved, the passed `conn` was modified
        break resolveloop;

    case exception:
        // Recoverable
        dealWithException(attempt.error);
        break;

    case failure:
        // Resolution failed without errors
        failGracefully(attempt.error);
        break;

    case error:
        // Unrecoverable
        dealWithError(attempt.error);
        return;
    }
}

// Address resolved

Meta