Exception thrown when OpenSSL functions return a non-1 error code, such as when the OpenSSL context could not be setup, or when it could not establish an SSL connection from an otherwise live connection.
Exception thrown when a certificate or a private key file could not be found.
Exception thrown when a socket send action returned Socket.ERROR.
Fiber function that tries to connect to IPs in the ips array of the passed Connection, yielding at certain points throughout the process to let the calling function do stuff in between connection attempts.
Given an address and a port, resolves these and populates the array of unique Address IPs inside the passed Connection.
Functions and state needed to maintain a connection.
Embodies the idea of a connection attempt.
Embodies the idea of a listening attempt.
Embodies the idea of an address resolution attempt.
import std.concurrency : Generator; Connection conn; bool abort; // Set to true if something goes wrong conn.reset(); bool useIPv6 = false; enum resolveAttempts = 10; auto resolver = new Generator!ResolveAttempt(() => resolveFiber(conn, "irc.libera.chat", 6667, useIPv6, resolveAttempts, abort)); resolver.call(); resolveloop: foreach (const attempt; resolver) { // attempt is a yielded `ResolveAttempt` // switch on `attempt.state`, deal with it accordingly } // Resolution done enum connectionRetries = 10; auto connector = new Generator!ConnectionAttempt(() => connectFiber(conn, false, connectionRetries, abort)); connector.call(); connectorloop: foreach (const attempt; connector) { // attempt is a yielded `ConnectionAttempt` // switch on `attempt.state`, deal with it accordingly } // Connection established enum timeoutSeconds = 600; auto listener = new Generator!ListenAttempt(() => listenFiber(conn, abort, timeoutSecond)); listener.call(); foreach (const attempt; listener) { // attempt is a yielded `ListenAttempt` doThingsWithLineFromServer(attempt.line); // program logic goes here }
Functionality related to connecting to a server over the Internet.
Includes Fibers that help with resolving the address of, connecting to, and reading full string lines from a server.
Having them as Fibers means a program can do address resolution, connecting and reading while retaining the ability to do other stuff concurrently. This means you can conveniently run code in between each connection attempt, for instance, without breaking the program's flow.