Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



How to initiate the discovery procedure

These code fragments illustrate initiation of the discovery procedure for the primary device.

TInt ret;
//
// MAKING HOST RESOLVER
//
RHostResolver hr1;
TProtocolDesc pInfo;
ret=hr1.Open(ss,pInfo.iAddrFamily,pInfo.iProtocol);
    // ret should be KErrNone

    // created host resolver: pInfo.iName
    // address family is: pInfo.iAddrFamily
    // socket type is: pInfo.iSockType
    // protocol is: pInfo.iProtocol

//
// MAKING SOCKET
//
RSocket sock1;
ret=sock1.Open(ss,pInfo.iAddrFamily,pInfo.iSockType,pInfo.iProtocol);
    // ret should be KErrNone

//
// SET OPTION ON 1 SLOT DISCOVERY
//

TPckgBuf<TUint> buf(1);
sock1.SetOpt(KDiscoverySlotsOpt,KLevelIrlap,buf);

//
// GET HOST BY NAME
//
TNameEntry log;
THostName name;
ret=hr1.GetByName(name,log); // Finds all IrLAP stations.
TIrdaSockAddr addr(log().iAddr); // Takes a TSockAddr and
if (ret==KErrNone) // casts it to a TIrdaSockAddr.
     {
    // Remote machine dev addr: addr.GetRemoteDevAddr()
    // Host machine dev addr: addr.GetHostDevAddr()
    // Remote machine solicited: addr.GetSolicitedStatus()
    // Rete machine sniff status: addr.GetSniffStatus()
    // Remote machine Irlap version: addr.GetIrlapVersion()
    // Remote no.of service hint bytes: addr.GetServiceHintByteCount()
    // Remote first service hint byte: addr.GetFirstServiceHintByte()
    // Remote machine character set: addr.GetCharacterSet()
    // Remote machine name: log().iName;
     }
else
 {
    // No EPOC devices discovered
 }

//
// CLOSING HOST RESOLVER
//
hr1.Close();

//
// CLOSING SOCKET
//
sock1.Close();


Note