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
// Lets first check are we already connected.
for (TUint i = 1; i <= connectionCount; i++)
if (connectionInfo().iIapId == iIap)
connected = ETrue;
// Not yet connected, start connection
//Define preferences for connection
//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?