AsyncTCPConnection

Wraps a TCP stream between 2 network adapters, using a custom handler to signal related events. Many of these objects can be active concurrently in a thread if the event loop is running and the handlers do not block.

Constructors

this
this(EventLoop evl, fd_t preInitializedSocket = fd_t.init)

Members

Functions

host
typeof(this) host(string hostname, size_t port)

(Blocking) Resolves the specified host and resets the peer to this address. Use AsyncDNS for a non-blocking resolver. (only usable before connecting).

ip
typeof(this) ip(string ip, size_t port)

Sets the peer to the specified IP address and port. (only usable before connecting).

kill
bool kill(bool forced = false)

Removes the connection from the event loop, closing it if necessary, and cleans up the underlying resources.

recv
long recv(ref ubyte[] ub)

Receive data from the underlying stream. To be used when TCPEvent.READ is received by the callback handler. IMPORTANT: This must be called until is returns a lower value than the buffer!

run
bool run(void delegate(TCPEvent) del)

Starts the connection by registering the associated callback handler in the underlying OS event loop.

run
bool run(TCPEventHandler del)
send
long send(in ubyte[] ub)

Send data through the underlying stream by moving it into the OS buffer.

setOption
bool setOption(TCPOption op, in T val)

Changes the default OS configurations for this underlying TCP Socket.

Properties

inbound
bool inbound [@property getter]

Returns true if this connection was accepted by an AsyncTCPListener instance.

isConnected
bool isConnected [@property getter]

Returns false if the connection has gone.

local
NetworkAddress local [@property getter]

Returns the OS-specific structure of the internet address for the local end of the connection.

noDelay
bool noDelay [@property setter]

Disables(true)/enables(false) nagle's algorithm (default:enabled).

peer
NetworkAddress peer [@property getter]

Returns the OS-specific structure of the internet address of the remote network adapter

peer
NetworkAddress peer [@property setter]

Sets the remote address as an OS-specific structure (only usable before connecting).

Meta