Connection

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

Constructors

this
this(Socket conn)

Constructor used by a ServerSocket for new connections

this
this()
Undocumented in source.

Members

Aliases

send
alias send = IConnection.send

Append data to the send buffer.

Functions

bytesQueued
size_t bytesQueued(int priority)

Returns the number of queued bytes at the given priority.

clearQueue
void clearQueue(int priority)

Cancel all queued Data packets with the given priority. Does not cancel any partially-sent Data.

disconnect
void disconnect(string reason, DisconnectType type)

Close a connection. If there is queued data waiting to be sent, wait until it is sent before disconnecting. The disconnect handler will be called immediately, even when not all data has been flushed yet.

doReceive
sizediff_t doReceive(void[] buffer)
Undocumented in source.
doSend
sizediff_t doSend(const(void)[] buffer)
Undocumented in source.
onError
void onError(string reason)

Called when an error occurs on the socket.

onReadable
void onReadable()

Called when a socket is readable.

packetsQueued
size_t packetsQueued(int priority)

Returns the number of queued Data at the given priority.

queuePresent
bool queuePresent(int priority)

Returns true if there are any queued Data which have not yet begun to be sent.

send
void send(Data[] data, int priority)

Append data to the send buffer.

updateFlags
void updateFlags()
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

handleBufferFlushed
BufferFlushedHandler handleBufferFlushed [@property setter]

Callback setter for when all queued data has been sent.

handleConnect
ConnectHandler handleConnect [@property setter]

Callback for when a connection has been established.

handleDisconnect
DisconnectHandler handleDisconnect [@property setter]

Callback for when a connection was closed.

handleReadData
ReadDataHandler handleReadData [@property setter]

Callback for incoming data. Data will not be received unless this handler is set.

state
ConnectionState state [@property getter]

Get connection state.

writePending
bool writePending [@property getter]

Returns true if any queues have pending data.

Static variables

inBuffer
Data inBuffer;
Undocumented in source.

Variables

doReceiveEOF
enum sizediff_t doReceiveEOF;
Undocumented in source.
outQueue
DataVec[MAX_PRIORITY + 1] outQueue;

The send buffers.

partiallySent
int partiallySent;

Whether the first item from this queue (if any) has been partially sent (and thus can't be canceled).

Inherited Members

From GenericSocket

__anonymous
mixin SocketMixin

Declares notifyRead and notifyWrite.

conn
Socket conn;

The socket this class wraps.

onReadable
void onReadable()
Undocumented in source. Be warned that the author may not have intended to support it.
onWritable
void onWritable()
Undocumented in source. Be warned that the author may not have intended to support it.
onError
void onError(string )
Undocumented in source. Be warned that the author may not have intended to support it.
socket
Socket socket [@property getter]

Retrieve the socket class this class wraps.

_address
Address _address [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
localAddress
alias localAddress = _address!true
Undocumented in source.
remoteAddress
alias remoteAddress = _address!false
Undocumented in source.
_addressStr
string _addressStr [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
localAddressStr
alias localAddressStr = _addressStr!true
Undocumented in source.
remoteAddressStr
alias remoteAddressStr = _addressStr!false
Undocumented in source.
daemonRead
bool daemonRead;

Don't block the process from exiting, even if the socket is ready to receive data. TODO: Not implemented with libev

daemonWrite
bool daemonWrite;

Don't block the process from exiting, even if the socket is ready to send data. TODO: Not implemented with libev

daemon
deprecated alias daemon = daemonRead
Undocumented in source.
setKeepAlive
void setKeepAlive(bool enabled, int time, int interval)

Enable TCP keep-alive on the socket with the given settings.

toString
string toString()

Returns a string containing the class name, address, and file descriptor.

From IConnection

MAX_PRIORITY
enum MAX_PRIORITY;
DEFAULT_PRIORITY
enum DEFAULT_PRIORITY;

send queues data for sending in one of five queues, indexed by a numeric priority. MAX_PRIORITY is the highest (least urgent) priority index. DEFAULT_PRIORITY is the default priority

defaultDisconnectReason
auto defaultDisconnectReason;

This is the default value for the disconnect reason string parameter.

state
ConnectionState state [@property getter]

Get connection state.

connected
deprecated bool connected [@property getter]

Has a connection been established?

disconnecting
deprecated bool disconnecting [@property getter]

Are we in the process of disconnecting? (Waiting for data to be flushed)

send
void send(Data[] data, int priority)
void send(Data datum, int priority)

Queue Data for sending.

disconnect
void disconnect(string reason, DisconnectType type)

Terminate the connection.

ConnectHandler
alias ConnectHandler = void delegate()

Callback setter for when a connection has been established (if applicable).

handleConnect
ConnectHandler handleConnect [@property setter]
Undocumented in source.
ReadDataHandler
alias ReadDataHandler = void delegate(Data data)

Callback setter for when new data is read.

handleReadData
ReadDataHandler handleReadData [@property setter]
Undocumented in source.
DisconnectHandler
alias DisconnectHandler = void delegate(string reason, DisconnectType type)

Callback setter for when a connection was closed.

handleDisconnect
DisconnectHandler handleDisconnect [@property setter]
Undocumented in source.
BufferFlushedHandler
alias BufferFlushedHandler = void delegate()

Callback setter for when all queued data has been sent.

handleBufferFlushed
BufferFlushedHandler handleBufferFlushed [@property setter]
Undocumented in source.

Meta