CProtocolBase Class Reference

class CProtocolBase : public CBase

Protocols created by protocol families must be instances of sub-classes of the abstract CProtocolBase . Since v5.0

Inherits from

Public Member Functions
CProtocolBase ()
~CProtocolBase ()
IMPORT_C void BindL ( CProtocolBase *, TUint )
IMPORT_C void BindToL ( CProtocolBase *)
IMPORT_C void Close ()
IMPORT_C void CloseNow ()
IMPORT_C void Error ( TInt , CProtocolBase *)
IMPORT_C TInt GetOption ( TUint , TUint , TDes8 &, CProtocolBase *)
void Identify ( TServerProtocolDesc *)
IMPORT_C void InitL ( TDesC &)
IMPORT_C CHostResolvProvdBase * NewHostResolverL ()
IMPORT_C CNetDBProvdBase * NewNetDatabaseL ()
IMPORT_C CServProviderBase * NewSAPL ( TUint )
IMPORT_C CServiceResolvProvdBase * NewServiceResolverL ()
IMPORT_C void Open ()
IMPORT_C void Process ( RMBufChain &, CProtocolBase *)
IMPORT_C void Process ( TDes8 &, TSockAddr *, TSockAddr *, CProtocolBase *)
CProtocolFamilyBase * ProtocolFamily ()
TInt RefCount ()
IMPORT_C TInt Send ( RMBufChain &, CProtocolBase *)
IMPORT_C TInt Send ( TDes8 &, TSockAddr *, TSockAddr *, CProtocolBase *)
IMPORT_C TInt SetOption ( TUint , TUint , const TDesC8 &, CProtocolBase *)
IMPORT_C void StartL ()
IMPORT_C void StartSending ( CProtocolBase *)
IMPORT_C TPtrC Tag ()
Protected Member Functions
IMPORT_C void CanClose ()
Private Member Functions
void TryDelete ()
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Private Attributes
CProtocolRef * iManagerRef
TInt iRefCount

Constructor & Destructor Documentation

CProtocolBase()

IMPORT_C CProtocolBase ( )

Constructor for the Protocol Base

~CProtocolBase()

IMPORT_C ~CProtocolBase ( ) [virtual]

Destroy the Protocol Base

Member Functions Documentation

BindL(CProtocolBase *, TUint)

IMPORT_C void BindL ( CProtocolBase * protocol,
TUint id
) [virtual]

This function panics with a panic number of EDoesNotBindBelow.

Parameters

CProtocolBase * protocol The higher level protocol requesting to bind
TUint id The ID number of the protocol requesting to bind

BindToL(CProtocolBase *)

IMPORT_C void BindToL ( CProtocolBase * protocol ) [virtual]

This function panics with a panic number of EDoesNotBindAbove.

Parameters

CProtocolBase * protocol The lower level protocol whose bind function must be called.

CanClose()

IMPORT_C void CanClose ( ) [protected]

Called by derived classes when an acceptable closedown condition has been reached.

Derived classes should not override this function.

CloseNow() for more details.

Close()

IMPORT_C void Close ( ) [virtual]

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.

CloseNow()

IMPORT_C void CloseNow ( ) [virtual]

Closes the protocol.

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() .

Error(TInt, CProtocolBase *)

IMPORT_C void Error ( TInt anError,
CProtocolBase * aSourceProtocol = NULL
) [virtual]

This function panics with a panic number of EErrorCallNotHandled unless the error is KErrCancel which is simply ignored.

Parameters

TInt anError The error code
CProtocolBase * aSourceProtocol = NULL The protocol raising the error

GetOption(TUint, TUint, TDes8 &, CProtocolBase *)

IMPORT_C TInt GetOption ( TUint level,
TUint name,
TDes8 & option,
CProtocolBase * aSourceProtocol = NULL
) [virtual]

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() .

Parameters

TUint level
TUint name
TDes8 & option
CProtocolBase * aSourceProtocol = NULL The protocol making the request.

Identify(TServerProtocolDesc *)

void Identify ( TServerProtocolDesc * aProtocolDesc ) const [pure virtual]

Fills in the passed TServerProtocolDesc with data describing the protocol.

Parameters

TServerProtocolDesc * aProtocolDesc Protocol description object to fill in

InitL(TDesC &)

IMPORT_C void InitL ( TDesC & aTag ) [virtual]

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.

If the protocol encounters any errors it should leave.

Note:

This implementation does nothing.

Parameters

TDesC & aTag The string identifier for the protocol as given by its section header in esock.ini

NewHostResolverL()

IMPORT_C CHostResolvProvdBase * NewHostResolverL ( ) [virtual]

This function panics with a panic number of EBadHostResolver.

NewNetDatabaseL()

IMPORT_C CNetDBProvdBase * NewNetDatabaseL ( ) [virtual]

This function panics with a panic number of EBadNetDBRequest.

NewSAPL(TUint)

IMPORT_C CServProviderBase * NewSAPL ( TUint aProtocol ) [virtual]

Creates a new service access point.

If the protocol cannot create the CServProviderBase for any reason, it should leave.

Parameters

TUint aProtocol Protocol.

NewServiceResolverL()

IMPORT_C CServiceResolvProvdBase * NewServiceResolverL ( ) [virtual]

This function panics with a panic number of EBadServiceResolver.

Open()

IMPORT_C void Open ( ) [virtual]

Opens a client connection.

The default implementation simply increments the reference count.

Any implementations by derived classes should call this base class implementation.

Process(RMBufChain &, CProtocolBase *)

IMPORT_C void Process ( RMBufChain & ,
CProtocolBase * aSourceProtocol = NULL
) [virtual]

This function panics with a panic number of ECantProcessMbufs.

Parameters

RMBufChain &
CProtocolBase * aSourceProtocol = NULL

Process(TDes8 &, TSockAddr *, TSockAddr *, CProtocolBase *)

IMPORT_C void Process ( TDes8 & aPDU,
TSockAddr * from,
TSockAddr * to = NULL,
CProtocolBase * aSourceProtocol = NULL
) [virtual]

This function panics with a panic number of ECantProcessDescriptors.

Parameters

TDes8 & aPDU The datagram to process.
TSockAddr * from
TSockAddr * to = NULL
CProtocolBase * aSourceProtocol = NULL The higher level protocol which we want to process our incoming datagram.

ProtocolFamily()

CProtocolFamilyBase * ProtocolFamily ( )

Get our family - through the manager ref.

RefCount()

TInt RefCount ( ) const [inline]

Reference counting by protocols created by protocol families.

Send(RMBufChain &, CProtocolBase *)

IMPORT_C TInt Send ( RMBufChain & aPDU,
CProtocolBase * aSourceProtocol = NULL
) [virtual]

This function panics with a panic number of ECantSendMBufs.

Parameters

RMBufChain & aPDU
CProtocolBase * aSourceProtocol = NULL

Send(TDes8 &, TSockAddr *, TSockAddr *, CProtocolBase *)

IMPORT_C TInt Send ( TDes8 & aPDU,
TSockAddr * to,
TSockAddr * from = NULL,
CProtocolBase * aSourceProtocol = NULL
) [virtual]

This function panics with a panic number of ECantSendDescriptors.

Parameters

TDes8 & aPDU The datagram to be sent.
TSockAddr * to
TSockAddr * from = NULL
CProtocolBase * aSourceProtocol = NULL The protocol from which the data has been sent.

SetOption(TUint, TUint, const TDesC8 &, CProtocolBase *)

IMPORT_C TInt SetOption ( TUint level,
TUint name,
const TDesC8 & option,
CProtocolBase * aSourceProtocol = NULL
) [virtual]

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.

Parameters

TUint level
TUint name
const TDesC8 & option
CProtocolBase * aSourceProtocol = NULL The protocol making the request.

StartL()

IMPORT_C void StartL ( ) [virtual]

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.

If a protocol cannot start to process data (for example it may not have bound correctly) it should leave.

Note:

This implementation does nothing.

StartSending(CProtocolBase *)

IMPORT_C void StartSending ( CProtocolBase * aProtocol ) [virtual]

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.

Note:

This implementation does nothing.

Parameters

CProtocolBase * aProtocol The calling protocol

Tag()

IMPORT_C TPtrC Tag ( )

Gets a TPtrC to the protocol's tag name. The default implementation returns the tag passed to Init().

TryDelete()

void TryDelete ( ) [private]

delete Protocol Base if ref count <0 Used from Protocol manager cleanup stack entries

Member Data Documentation

CProtocolRef * iManagerRef

CProtocolRef * iManagerRef [private]

TInt iRefCount

TInt iRefCount [private]