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
,
const bool* abort
)

Parameters

conn Connection

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*

Pointer to the "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,
        abort));

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