Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Snip.AbstractConnection

Feature notes: Snif remoting framework (concepts)

Classes, interfaces and records

classEsnipError

inherits from Exception

Root of the snip exception hierarchy. Declared here because every snip unit already builds on this one, so a single handler catches the whole transport.

(no public members)

classEsnipProtocol

inherits from EsnipError

The peer sent something the wire format does not allow: a bad header, an over-long length prefix, an unknown field or value kind, or a message kind that does not belong at this point in the exchange.

(no public members)

classEsnipState

inherits from EsnipError

The connection object was asked to do something its current state does not allow - connecting one that is already bound, reading a second request while one is pending, or using a connection that is not active.

(no public members)

classEsnipClosed

inherits from EsnipError

The peer closed, or the transport dropped, before the exchange finished.

(no public members)

classEsnipTimeout

inherits from EsnipError

A bounded wait ran out with the transport STILL UP: the peer simply said nothing in the time allowed.

DELIBERATELY NOT A LEAF OF EsnipClosed. A timeout is a claim that the connection is alive, so every handler already written to read EsnipClosed as "the peer has gone - drop it, reconnect, fail the session" would draw exactly the opposite conclusion from this one. It sits beside EsnipClosed under the common root instead, where a handler that wants "any transport failure" still catches it through EsnipError and one that wants "the peer is gone" no longer catches it by accident.

(no public members)

interfaceIsnipConnection

IsnipConnection is the transport-agnostic wire abstraction that the Snif/Snic class-remoting framework (see StreamSec.Snif.ClassServer / StreamSec.Snic.ClassClient) uses to move TsnifRequest/TsnifResponse messages over whatever the actual connection is (TLS, SSH, ...). Application code normally never implements this interface directly: it is obtained from an OnGetConnection-style event or from a concrete transport connection (e.g. TsnipClientTLSOctetConnection / TsnipServerTLSOctetConnection in StreamSec.Snip.TLSOctetConnection, or their SSH counterparts) and then just holds/passes it around. The methods below behave differently depending on which side of the connection created them: a client-role connection drives SendRequest/WaitForMessage/ReadResponse in a call-and-wait pattern, while a server-role connection drives ReadRequest/ SendResponse and typically cannot honor WaitForMessage (see the concrete Server* implementations, which raise there).

procedure SetName(const Value: string);
Setter for Name; see the Name property below for what the value means and who assigns it.
function GetName: string;
Getter for Name; see the Name property below.
function GetHasData: Boolean;
Getter for HasData; see the HasData property below.
function GetIsActive: Boolean;
Getter for IsActive; see the IsActive property below.
function GetConversionKind: TsnifConversionKind;
Getter for ConversionKind; see the ConversionKind property below.
function ReadRequest(const aRequest: TsnifRequest): Boolean;
Pulls the next inbound TsnifRequest off the wire into aRequest. This is the server-side half of the request/response exchange: a server-role connection (e.g. TsnipServerTLSOctetConnection) implements this by waiting for and decoding a request message; a client-role connection instead expects Wait... Full description »
function ReadResponse(const aRequest: TsnifResponse): Boolean;
Pulls the next inbound TsnifResponse off the wire into aRequest. On the client side this is how the app retrieves the reply to a request it sent with SendRequest (see TsnicClassClient's SendRequest/ReadResponse pairing); on the server side it is used only for the reverse direction, i.e. reading the client's answer to a server-initiated callback.
function SendRequest(const aRequest: TsnifRequest): Boolean;
Sends aRequest over the wire. Application code on the client side calls this to invoke a remote method (see TsnicClassClient.ProcessCall/ProcessRead/ ProcessWrite); a server-role connection uses it only when issuing a callback back to the client.
function SendResponse(const aRequest: TsnifResponse): Boolean;
Sends aRequest (a TsnifResponse) over the wire. This is how a server-role connection returns the result of a remote call (see TsnifClassServer's request-processing loop); a client-role connection uses it only to answer a server-initiated callback.
function WaitForMessage: TsnipMessageKind;
Blocks until the next message kind is known and returns it. Meaningful mainly on the client side, where it distinguishes an ordinary reply (msgResponse) from an incoming server callback (msgRequest) that must be serviced before the original call can complete (see TsnicClassClient. Full description »
function Close: Boolean;
Closes the underlying transport connection. An application ends a Snif/Snic session by calling this (directly, or indirectly by freeing the component that owns the connection); on the server side it is also invoked internally when a close message arrives from the peer.
function Equals(Obj: TObject): Boolean;
Identity comparison used by the server to recognize that a freshly accepted connection is the SAME logical connection object already on file for a session (see TsnifClassServer.NewConnection, which calls Result.Connection.Equals(aConn) when re-attaching to an existing TsnifContext by Name). Not normally called directly by application code.
property IsActive: Boolean read GetIsActive;
True once IsActive/RawConnected report the transport as up. Application code (and TsnifClassServer.NewConnection) checks this to decide whether a same-named connection can be safely replaced/reattached or is still busy.
property HasData: Boolean read GetHasData;
True when a full message is available to be read without blocking; used internally by the polling WaitForData/GetHasData loop in the concrete Octet connection implementations rather than by application code directly.
property Name: string read GetName write SetName;
The connection's session/context key. On the server side this is how TsnifClassServer.NewConnection looks up (or creates) the matching TsnifContext (FindContextByName) and is set back onto the connection once a context exists; a reconnecting client presents its previous Name so the server can reattach it to the same session.
property ConversionKind: TsnifConversionKind read GetConversionKind;
The wire encoding (e.g. ckBytes) used to marshal request/response argument values; both sides must agree on this so TsnifRequest/TsnifResponse decode correctly. Application code typically leaves this at the transport's default rather than setting it directly.

classTsnipAbstractConnection

inherits from TInterfacedObject

implements IsnipConnection

destructor Destroy; override; function ReadRequest(const aRequest: TsnifRequest): Boolean; virtual; abstract; function ReadResponse(const aResponse: TsnifResponse): Boolean; virtual; abstract; function SendRequest(const aRequest: TsnifRequest): Boolean; virtual; abstract; function SendResponse(const aResponse: TsnifResponse): Boolean; virtual; abstract; function WaitForMessage: TsnipMessageKind; virtual; abstract; function Close: Boolean; virtual; abstract; property IsActive: Boolean read GetIsActive; property HasData: Boolean read GetHasData; property Name: string read GetName write SetName; property ConversionKind: TsnifConversionKind read GetConversionKind;

Types (enumerations, sets, aliases)

enumTsnipMessageKind

  TsnipMessageKind = (msgRequest,msgResponse,msgClose);

enumTsnipWaitOutcome

How a bounded wait for the next inbound frame ended. THREE VALUES RATHER THAN A BOOLEAN, because the two non-arrivals call for opposite answers and a False collapses them. swoTimeout means nothing came within the budget while the transport is still usable - look again, or give up on this read. swoClosed means nothing more can ever come. A caller that turns non-arrival into an exception has to be able to tell them apart, or it reports a dead connection that is in fact alive.

  TsnipWaitOutcome = (swoData,swoTimeout,swoClosed);