ae.net.asockets

Asynchronous socket abstraction.

Public Imports

ae.sys.data
public import ae.sys.data;
Undocumented in source.

Members

Classes

Connection
class Connection

Implementation of IConnection using a socket. Implements receiving data when readable and sending queued data when writable.

ConnectionAdapter
class ConnectionAdapter

Base class for a connection adapter. By itself, does nothing.

Duplex
class Duplex

Separates reading and writing, e.g. for stdin/stdout.

FileConnection
class FileConnection

A POSIX file stream. Allows adding a file (e.g. stdin/stdout) to the socket manager. Does not dup the given file descriptor, so "disconnecting" this connection will close it.

GenericSocket
class GenericSocket

General methods for an asynchronous socket.

LineBufferedAdapter
class LineBufferedAdapter

Adapter for connections with a line-based protocol. Splits data stream into delimiter-separated lines.

SocketConnection
class SocketConnection

An asynchronous socket-based connection.

SocketServer
class SocketServer

An asynchronous connection server for socket-based connections.

StreamConnection
class StreamConnection

Implements a stream connection. Queued Data is allowed to be fragmented.

TcpConnection
class TcpConnection

An asynchronous TCP connection.

TcpServer
class TcpServer

An asynchronous TCP connection server.

TimeoutAdapter
class TimeoutAdapter

Fires an event handler or disconnects connections after a period of inactivity.

UdpConnection
class UdpConnection

An asynchronous UDP stream. UDP does not have connections, so this class encapsulates a socket with a fixed destination (sendto) address, and optionally bound to a local address. Currently received packets' address is not exposed.

Enums

ConnectionState
enum ConnectionState

Used to indicate the state of a connection throughout its lifecycle.

DisconnectType
enum DisconnectType

Classifies the cause of the disconnect. Can be used to decide e.g. when it makes sense to reconnect.

Functions

addIdleHandler
void addIdleHandler(SocketManager socketManager, void delegate() handler)

Register a function to be called when the event loop is idle, and would otherwise sleep.

disconnectable
bool disconnectable(ConnectionState state)

Returns true if this is a connection state for which disconnecting is valid. Generally, applications should be aware of the life cycle of their sockets, so checking the state of a connection is unnecessary (and a code smell). However, unconditionally disconnecting some connected sockets can be useful when it needs to occur "out-of-bound" (not tied to the application normal life cycle), such as in response to a signal.

onNextTick
void onNextTick(SocketManager socketManager, void delegate() dg)

Schedule a function to run on the next event loop iteration. Can be used to queue logic to run once all current execution frames exit. Similar to e.g. process.nextTick in Node.

removeIdleHandler
void removeIdleHandler(SocketManager socketManager, Args args)

Unregister a function previously registered with addIdleHandler.

Imports

Address (from std.socket)
public import std.socket : Address, AddressInfo, Socket;
Undocumented in source.
AddressInfo (from std.socket)
public import std.socket : Address, AddressInfo, Socket;
Undocumented in source.
Socket (from std.socket)
public import std.socket : Address, AddressInfo, Socket;
Undocumented in source.

Interfaces

IConnection
interface IConnection

Common interface for connections and adapters.

Structs

SocketManager
struct SocketManager

libev-based event loop implementation.

SocketManager
struct SocketManager

select-based event loop implementation.

Variables

eventCounter
int eventCounter;

Flags that determine socket wake-up events.

socketManager
SocketManager socketManager;

The default socket manager.

Meta

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Authors

Stéphan Kochen <stephan@kochen.nl> Vladimir Panteleev <ae@cy.md> Vincent Povirk <madewokherd@gmail.com> Simon Arlott