DId anyone know why this in one moment shows the correct info that the other device is found and in the other that the device doesn't found but its also in the envoirment..

CODE:


void CBTFinderAppUi::BluetoothCheck()
{



RSocketServ iSocketServer;
RSocket iSendingSocket;
iSocketServer.Connect();
TProtocolDesc pInfo;
TBool BTFound;
TInt KRfcommChannel;

KRfcommChannel = 1;

User::LeaveIfError(iSocketServer.FindProtocol(_L("BTLinkManager"),pInfo));

RHostResolver hr;
User::LeaveIfError(hr.Open(iSocketServer,pInfo.iAddrFamily,pInfo.iProtocol));

TInquirySockAddr addr;
TNameEntry entry;
addr.SetIAC(KGIAC);
addr.SetAction(KHostResInquiry|KHostResName);
TRequestStatus status;
hr.GetByAddress(addr, entry, status);
User::WaitForRequest(status);

TBool BTSERVER;
BTSERVER = EFalse;

if (entry().iName.Match( _L("SERVER") ))
{
BTSERVER = ETrue;
}


while (hr.Next(entry) != KErrHostResNoMoreResults)
{
if (entry().iName.Match( _L("SERVER") ))
{
BTSERVER = ETrue;
}
}

if(BTSERVER)
{
CEikonEnv::Static()->AlertWin(_L("Status:"),_L("in envoirment"));
}else{
CEikonEnv::Static()->AlertWin(_L("Status:"),_L("not in envoirement"));
}


}