Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to write CProtocolFamilyBase::ProtocolList()

The ProtocolList() function is called to return a list of all the protocols in the protocol family.

The following example demonstrates an implementation of this function in the derived-class CIpcProtocolFamily:

TUint CIpcProtocolFamily::ProtocolList(TServerProtocolDesc*&
        aProtocolList)
    {
    TRAPD(ret,aProtocolList=new (ELeave) TServerProtocolDesc[2]);
    if(ret!=KErrNone)
        return 0;

    // Stream protocol
    _LIT(KProtocolName1,"IPC Stream");
    aProtocolList[0].iName=KProtocolName1;
    aProtocolList[0].iAddrFamily=KIPCAddrFamily;
    aProtocolList[0].iSockType=KSockStream;
    aProtocolList[0].iProtocol=KIPCStreamProtocol;

    aProtocolList[0].iVersion=TVersion(KES32MajorVersionNumber,
        KES32MinorVersionNumber,KES32BuildVersionNumber);
    aProtocolList[0].iByteOrder=ELittleEndian;
    aProtocolList[0].iServiceInfo=KIPCStreamServiceInfo;
    aProtocolList[0].iNamingServices=0;
    aProtocolList[0].iSecurity=KSocketNoSecurity;
    aProtocolList[0].iMessageSize=KSocketMessageSizeIsStream;
    aProtocolList[0].iServiceTypeInfo=ESocketSupport;
    aProtocolList[0].iNumSockets=KIPSNumberSockets;

    // Datagram protocol
    _LIT(KProtocolName2,"IPC Datagram");
    aProtocolList[1].iName=KProtocolName2;
    aProtocolList[1].iAddrFamily=KIPCAddrFamily;
    aProtocolList[1].iSockType=KSockDatagram;
    aProtocolList[1].iProtocol=KIPCDatagramProtocol;

    aProtocolList[1].iVersion=TVersion(KES32MajorVersionNumber,
        KES32MinorVersionNumber,KES32BuildVersionNumber);
    aProtocolList[1].iByteOrder=ELittleEndian;
    aProtocolList[1].iServiceInfo=KIPCDatagramServiceInfo;
    aProtocolList[1].iNamingServices=0;
    aProtocolList[1].iSecurity=KSocketNoSecurity;
    aProtocolList[1].iMessageSize=KSocketMessageSizeNoLimit;
    aProtocolList[1].iServiceTypeInfo=ESocketSupport;
    aProtocolList[1].iNumSockets=KIPSNumberSockets;
        return 2;
    }