Location:
es_prot.h
Link against: esock.lib
CProtocolBase
Supported from 5.0
Protocols created by protocol families must be instances of
sub-classes of the abstract CProtocolBase
.
|
Defined in CProtocolBase
:
BindL()
, BindToL()
, CanClose()
, Close()
, CloseNow()
, Error()
, GetOption()
, Identify()
, InitL()
, NewHostResolverL()
, NewNetDatabaseL()
, NewSAPL()
, NewServiceResolverL()
, Open()
, Process()
, Send()
, SetOption()
, StartL()
, StartSending()
, Tag()
Inherited from CBase
:
operator new()
virtual void InitL(TDesC& aTag);
Initialises a protocol before any binding is performed. A protocol can override it to create any further resources it may require — this might include allocating buffers, opening devices or reading more configuration information.
The default implementation does nothing.
|
|
virtual void StartL();
Indicates to a protocol that all binding has completed successfully and it can start processing datagrams. This is mainly of interest to the lowest levels of a protocol stack which would queue a read on the network media device driver in response to this call.
The default implementation does nothing.
|
virtual void BindTo(CProtocolBase* protocol, TUint id);
Instructs a lower level protocol to bind to a protocol higher up in
the stack. The protocol must call the Bind()
function of the
specified lower level protocol specifying itself as the source protocol.
The protocol must keep a record of who is binding to it, in order to send data.
The default implementation panics.
|
|
virtual void Bind(CProtocolBase *protocol, TUint id)=0;
Instructs a higher level protocol to bind to another protocol higher up on the stack.
The default implementation panics.
|
|
A protocol which is to provide socket services (i.e. it is at the highest
level of the stack) must provide one or more
CServProviderBase
-derived objects. These objects, known as service
access points, provide the means for the socket server to send data to and
receive data from a protocol (on behalf of its clients). Protocols that provide
host name resolution, network database access, or service resolution should
also provide suitable objects for these services.
virtual CHostResolvProvdBase* NewHostResolverL();
Creates a host name resolver service, if one is supplied by the
protocol. Return NULL
if no such service is supported.
|
virtual CNetDBProvdBase* NewNetDatabaseL();
Creates a network database access service, if one is supplied by the
protocol. Return NULL
if no such service is supported.
|
virtual CServProviderBase* NewSAPL(TUint aSocketType);
Creates a new service access point.
If the protocol cannot create the CServProviderBase
for any
reason, it should leave.
|
|
virtual CServiceResolvProvdBase* NewServiceResolverL();
Creates a service resolver service, if one is supplied by the protocol.
Return NULL
if no such service is supported.
|
virtual void Open();
Opens a client connection. The default implementation simply increments the reference count. Any implementations by derived classes should call this base class implementation.
virtual void Close();
Closes a client connection. The default implementation decrements the
reference count and calls CloseNow()
if no clients are connected.
Any implementations by derived classes should call this base class
implementation.
virtual void CloseNow();
Closes the protocol. It is called by Close()
when all
clients referencing a protocol have disconnected. The default implementation
simply deletes the object. Derived classes can implement this function to
provide a delayed closedown: for example, to allow reliable protocols to ensure
that all data has drained from the stack before it is deleted. When an
acceptable closedown condition has been reached, the protocol should call
CanClose()
.
void CanClose();
Called by derived classes when an acceptable closedown condition has been
reached. See CloseNow()
for more details. Derived classes should
not override this function.
Protocols which are bound to each other can expect various services from
each other and, in turn, must service the requests of other protocols. A
protocol which is bound to another protocol can send packets of data down the
stack using one of the two flavours of Send()
function. A protocol
which has had a protocol bind to it can deliver datagrams via that protocol
using one of the two flavours of Process()
function.
virtual TInt Send(TDes8& aPDU, TSockAddr* aTo, TSockAddr* aFrom=NULL,
CProtocolBase* aSourceProtocol=NULL);
Sends a datagram down the stack when called by a protocol module on any other protocol to which it has bound.
This version of the Send()
function should be used when
descriptor-based protocol data units are in use.
The aFrom
parameter is the address originating the send.
This is passed through as it may affect routing or something else, depending on
the particular protocol. Generally its value is the local address of the socket
sending the data.
|
|
virtual void Process(TDes8& aPDU, TSockAddr* aFrom, TSockAddr* aTo=NULL,
CProtocolBase* aSourceProtocol=NULL);
Processes a datagram when called by a protocol on any other (higher
level) protocol which has bound to it. The TSockAddr
specifies the
source address of the data. If this is not known the pointer should be
NULL
.
This version of the Process()
function should be used when
descriptor-based protocol data units are in use.
The aTo
and aFrom
parameters are client-side
structures used in functions like BindL()
and
SendTo()
. The actual internal format of the TSockAddr
is protocol specific — generally protocols will provide their own
TSockAddr
-derived class.
|
virtual void StartSending(CProtocolBase* aProtocol);
Indicates that data can now be sent. Implementations can call bound higher-level protocols and service access points in turn.
With Send()
, this function forms a flow control pair. A zero
return from a Send()
should flow control off the calling protocol.
StartSending()
acts as a flow control on.
|
virtual void GetOption(TUint aLevel,TUint aName,TDes8& anOption,
CProtocolBase* aSourceProtocol=NULL);
Gets options for the protocol on behalf of socket server clients.
The option parameter is protocol-defined — this is a generic API.
The protocol is passed in because you might get GetOption()
calls from multiple bindees — this is actually more meaningful for
SetOption()
.
|
virtual void SetOption(TUint aLevel, Tuint aName, const TDesC8& anOption,
CProtocolBase* aSourceProtocol=NULL)=0;
Sets options for the protocol on behalf of socket server clients.
The option parameter is protocol-defined — this is a generic API.
The protocol is passed in because you might get SetOption()
calls from multiple bindees and need to distinguish who is setting what.
|
virtual void Identify(TServerProtocolDesc* aProtocolDesc) const=0;
Fills in the passed TServerProtocolDesc
with data describing
the protocol.
|
TPtrC Tag();
Gets a TPtrC
to the protocol's tag name. The default
implementation returns the tag passed to Init()
.
|
virtual void Error(TInt anError,CProtocolBase* aSourceProtocol=NULL);
Propagates error conditions up the stack, eventually to socket service providers.
|