Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mobile.AsyncTLSReactor.IOCP

re-arm, close

Feature notes: TLS implementation notes (RFC map) · Async TLS socket server architecture

Classes, interfaces and records

recordTIoContext

Overlapped: TOverlapped;
<-- must be first
Op: tIoOp; Buf: WSABUF; Slab: PByte;
recv: pooled slab or nil (zero-byte); send: per-op sized
SlabPooled: Boolean;
recv pooled slab (return to pool) vs send GetMem
Hold: IInterface;
lifetime anchor: pins the CCB while the op is in flight
Next: PIoContext;
context free-list link
From: TSockAddrStorage;
ioRecvFrom: the sender, written by the system when the receive completes. Both MUST live as long as the operation, so they are here and not on a stack.
FromLen: Integer; UsesMessage: Boolean;
ioRecvFrom posted as WSARecvMsg (ECN reception on): the message header and its control data, which the system also writes on completion.
Msg: WSAMSG; Control: array [0..cDatagramEcnControlSize div SizeOf(NativeUInt) - 1] of NativeUInt;

classtIOCPReactor

(no public members)

classtIOCPWorker

inherits from TThread

constructor Create(aReactor: tIOCPReactor);

classtIOCPReactor

inherits from tAsyncReactor

constructor Create(aThreadCount: Integer); override; destructor Destroy; override; procedure Start; override; procedure Stop; override; procedure CloseSocketHandle(aHandle: TSocketHandle); override;
The platform close the base class delegates here (see tAsyncReactor).
procedure Attach(aConnection: tReactorConnection); override; procedure Detach(aConnection: tReactorConnection); override; function SupportsApplicationWork: Boolean; override;
Always returns True.
function PostReceive(aConnection: tReactorConnection): Boolean; override; function PostSend(aConnection: tReactorConnection; aData: Pointer; aLen: Integer): Boolean; override; function Nudge(aConnection: tReactorConnection): Boolean; override; function ConnectionCount: Integer; override;
Live registered connections. The drain loop of a graceful shutdown polls this.
function SnapshotConnections(out aConns: TArray<tReactorConnection>; out aHold: TArray<IInterface>): Integer; override;
Snapshot of the registry, each entry pinned by an interface reference parked in aHold so the raw object references stay valid for as long as the caller keeps aHold alive. Same technique Stop uses internally. Returns the count.
function SupportsDatagrams: Boolean; override;
Always returns True.
procedure AttachDatagram(aEndpoint: tReactorDatagramEndpoint); override; procedure DetachDatagram(aEndpoint: tReactorDatagramEndpoint); override; function SendDatagram(aEndpoint: tReactorDatagramEndpoint; aData: Pointer; aLen: Integer; const aTo: tSocketAddress; out aError: Integer): Boolean; override; function SendDatagramSegments(aEndpoint: tReactorDatagramEndpoint; aData: Pointer; aLen, aSegmentSize: Integer; const aTo: tSocketAddress; out aError: Integer): Integer; override; function SetDatagramEcnReception(aEndpoint: tReactorDatagramEndpoint; aEnabled: Boolean; out aError: Integer): Boolean; override; function SendDatagramEcn(aEndpoint: tReactorDatagramEndpoint; aData: Pointer; aLen: Integer; const aTo: tSocketAddress; aEcn: tDatagramEcn; out aError: Integer): Boolean; override; function SendDatagramSegmentsEcn(aEndpoint: tReactorDatagramEndpoint; aData: Pointer; aLen, aSegmentSize: Integer; const aTo: tSocketAddress; aEcn: tDatagramEcn; out aError: Integer): Integer; override; function DatagramEndpointCount: Integer; override; property ZeroByteRecv: Boolean read fZeroByteRecv write fZeroByteRecv;
When True, PostReceive posts a zero-byte WSARecv and the completion drains the socket synchronously (in order) before re-arming - keeps idle connections from pinning a slab in non-paged pool. Requires the handle to be non-blocking (Attach sets FIONBIO when this is on).

Types (enumerations, sets, aliases)

enumtIoOp

ioNudge is not a socket operation: it is a packet this reactor posts to its own port so that work decided on a foreign thread runs in a normal dispatch position instead. See tIOCPReactor.Nudge. ioRecvFrom is a datagram endpoint's receive, and the only op whose completion key is not a tReactorConnection.

  tIoOp = (ioRecv, ioSend, ioNudge, ioRecvFrom);

typePIoContext

Per-operation context. OVERLAPPED MUST be the first field so the LPWSAOVERLAPPED returned by GetQueuedCompletionStatus casts straight back to this record (field 0 sits at offset 0).

  PIoContext = ^TIoContext;

Routines