Connection

Functions and state needed to maintain a connection.

This is simply to decrease the amount of globals and to create some convenience functions.

Members

Functions

getSSLErrorMessage
auto getSSLErrorMessage(int code)

Returns the SSL error message for the passed SSL error code.

receive
auto receive(ubyte[] buffer)

Proxies calls to socket.receive.

receiveTimeout
auto receiveTimeout()

Accessor; returns the current receive timeout.

receiveTimeout
void receiveTimeout(uint dur)

Mutator; sets the receive timeout socket option to the passed duration.

reset
void reset()

(Re-)initialises the sockets and sets the IPv4 one as the active one.

resetSSL
void resetSSL()

Resets the SSL context and resources of this Connection.

sendTimeout
auto sendTimeout()

Accessor; returns the current send timeout.

sendTimeout
void sendTimeout(uint dur)

Mutator; sets the send timeout socket option to the passed duration.

sendline
void sendline(string rawline, uint maxLineLength, string linebreak)

Sends a line to the server.

setDefaultOptions
void setDefaultOptions(Socket socketToSetup)

Sets up sockets with the SocketOptions needed. These include timeouts and buffer sizes.

setTimeout
void setTimeout(SocketOption option, uint dur)

Sets the SocketOption.RCVTIMEO of the *current* Socket socket to the specified duration.

setup
void setup()

Initialises new Sockets and sets their options.

setupSSL
void setupSSL()

Sets up the SSL context for this connection.

teardown
void teardown()

Shuts down and closes the internal Sockets.

teardownSSL
void teardownSSL()

Frees SSL context and resources.

Variables

_receiveTimeout
uint _receiveTimeout;

Private cached received timeout setting.

_sendTimeout
uint _sendTimeout;

Private cached send timeout setting.

certFile
string certFile;

Path to a (.pem) SSL certificate file.

connected
bool connected;

Whether we are connected or not.

ips
Address[] ips;

IPs already resolved using resolveFiber.

privateKeyFile
string privateKeyFile;

Path to a private SSL key file.

socket
Socket socket;

Pointer to the socket of the AddressFamily we want to connect with.

socket4
Socket socket4;
socket6
Socket socket6;

Real IPv4 and IPv6 sockets to connect through.

ssl
bool ssl;

Whether or not this Connection should use SSL when sending and receiving.

sslContext
SSL_CTX* sslContext;

Private SSL context.

sslInstance
SSL* sslInstance;

OpenSSL requests.ssl_adapter.SSL instance, for use with SSL connections.