I am developing a program for nokia6600.In my program, a dialog will pop up to ask
user to select a access point to connect to internet.My code is following:
void CApEngine::ConnectBySelect()
{
CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeIAP);
CApSettingsHandler* pApSettingDlg;
pApSettingDlg = CApSettingsHandler::NewLC(ETrue, EApSettingsSelListIsListPane,
EApSettingsSelMenuSelectNormal, KEApIspTypeAll, EApBearerTypeAll, KEApSortNameAscending);

TUint32 originallyFocused = 0;
TUint32 aSelectedIap = 0;

pApSettingDlg->RunSettingsL(originallyFocused, aSelectedIap);

if(aSelectedIap)
{
CApUtils* apUtils = CApUtils::NewLC(*db);
// Convert IAP id to CommsDb id
m_iWapIap = apUtils->IapIdFromWapIdL(aSelectedIap);
m_iWapUid = aSelectedIap;
CleanupStack::PopAndDestroy(apUtils);
}

CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeIAP);

CCommsDbConnectionPrefTableView* connPrefView;
connPrefView = db->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionOutgoing);

TInt err = connPrefView->GotoFirstRecord();

CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref aPref;

while (KErrNone == err)
{
connPrefView->ReadConnectionPreferenceL(aPref);

if(aPref.iBearer.iIapId == m_iWapIap)
{
aPref.iDialogPref = ECommDbDialogPrefDoNotPrompt;
aPref.iDirection=ECommDbConnectionDirectionOutgoing;

CStoreableOverrideSettings *m_overrides = CStoreableOverrideSettings::NewL(CStoreableOverrideSettings::EParamListPartial,EDatabaseTypeIAP);
m_overrides->SetConnectionPreferenceOverride(aPref);

User::LeaveIfError(m_iAgent.Open());
m_pConsole->HttpEventNotify(INTERNET_STATUS_CONNECTING_TO_AP);
m_iAgent.StartOutgoing(*m_overrides, iStatus);
SetActive();
break;
}
err = connPrefView->GotoNextRecord();
}
}

class CApEngine is derived form CActive.In CApEngine::RunL() , the return iStatus is KErrNone,
indicate that the connection is created(indeed, the G icon occur in my phone screen).Then I open
a socket to connect to server by name, but when resolving DNS, error occured.My code is as follow:
CApEngine::ConnectToServer(TDesC aServerName)
{
// Open channel to Socket Server
User::LeaveIfError(m_SocketServ.Connect());
// Initiate DNS
User::LeaveIfError(m_Resolver.Open(m_SocketServ, KAfInet, KProtocolInetUdp));
// DNS request for name resolution
m_Resolver.GetByName(aServerName, m_NameEntry, iStatus);
// Request time out
m_pTimer->After(m_nTimeOut);
SetActive();
}
But in RunL(), the return iStatus is not KErrNone,that is some error happen in resolving DNS.
Can anybody tell me why?
Thanks a lot in advance!