I'm developing an HTTP application that opens a GPRS connection without prompting the user (IAP to use, is defined in the program settings). Before opening a connection, I check if a connection already exists. Now, if some other program has already an active connection with the same IAP I want to connect with, I get into trouble. How can I use an IAP that is already connected. Here is my code:

// in header
RConnection iConnection;
RHTTPSession iHttpSession;
RSocketServ iSockServ;


// Lets first check are we already connected.
TUint connectionCount;
User::LeaveIfError(iConnection.EnumerateConnections(connectionCount));
TPckgBuf<TConnectionInfoV2> connectionInfo;
for (TUint i = 1; i <= connectionCount; i++)
{
User::LeaveIfError(iConnection.GetConnectionInfo(i, connectionInfo));
if (connectionInfo().iIapId == iIap)
{
connected = ETrue;
User::LeaveIfError(iConnection.Attach(connectionInfo, RConnection::EAttachTypeNormal));
break;
}
}

// Not yet connected, start connection
if (!connected)
{
//Define preferences for connection
TCommDbConnPref prefs;
prefs.SetIapId(iIap);
prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);

//Start Connection
User::LeaveIfError(iConnection.Start(prefs));
}

//Set properties for session
RStringPool strP = iHttpSession.StringPool();
RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo();
connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable() ), THTTPHdrVal (iSockServ.Handle()) );
TInt connPtr = REINTERPRET_CAST(TInt, &iConnection);
connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), THTTPHdrVal (connPtr) );


This works fine if I open the connection and also if I try to open the connection when I'm already connected with connection I started. But, if some other program has connected with the IAP I want to use, the user is prompted with the IAP selection dialog when the HTTP connection is first used. The iConnection.Attach is the way I tried to use the existing connection but it doesn't work. Any ideas?