×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    1

    Question GPRS connection stays active when using Explicit connection

    Dear All,

    The program opens operates and closes explicit connection according to "Developing S60 application".
    When several sockets are open, some of them are getting data, some not, application is closed. The sequence is:
    1. Close all sockets RSocket::CancelAll(), RSocket::Close
    2. RConnection::Close()
    3. RSocketServ::Close()
    Problem:
    Connection stays active.
    Comments:
    1. When all sockets get all the data, connection gets deactivated successfully.
    2. When RConnection::Stop() is used it is also deactivated, however this approach is not recommended.

    If you could give comments on this case, that would be great!

    Thanks in advance....

  2. #2
    Registered User
    Join Date
    Aug 2009
    Posts
    41

    Re: GPRS connection stays active when using Explicit connection

    here is the code
    TInt err;
    if( iConnectionSetupDone ) {
    MYdebug->Output8(_L8("I"), _L8("SetupConnectionL"), _L8("connection already established"));
    return;
    }

    TUint32 iAccesspoint;

    if( ! MYconf->GetAccesspoint(iAccesspoint) ) {
    //if( !CFileOperations::GetSettingsFlag())
    MYdebug->Output8(_L8("I"), _L8("SetupConnectionL"), _L8("GetAccesspoint not done yet, how come?"));
    return;
    } /**/
    MYdebug->Output8(_L8("I"), _L8("SetupConnectionL"), _L8("setup starting"));

    TInt bearerFilter = EApBearerTypeAllBearers;//EApBearerTypeGPRS;
    MYdebug->Output8(_L8("I"), _L8("IAP="), iAccesspoint);

    SelectIAP:
    if( iAccesspoint <= 0 ) {

    MYdebug->Output8(_L8("I"), _L8("SetupConnectionL"), _L8("Select_iAP"));
    CActiveApDb* aDb = CActiveApDb::NewL();
    CleanupStack::PushL(aDb);

    CApSettingsHandler* settings = CApSettingsHandler::NewLC(
    *aDb,
    ETrue,
    EApSettingsSelListIsPopUp,
    EApSettingsSelMenuSelectNormal,
    KEApIspTypeAll,
    bearerFilter,
    KEApSortNameAscending,
    0,
    EVpnFilterBoth,
    ETrue);

    TInt iapRet = settings->RunSettingsL(0, iSelectedIap);

    CleanupStack::PopAndDestroy(settings);
    CleanupStack::PopAndDestroy(aDb);
    ///MYsettings->SetIap(iSelectedIap);
    iAccesspoint = iSelectedIap;
    MYconf->SetAccesspoint(iAccesspoint);

    //CFileOperations::WriteSettings();
    }

    if( iAccesspoint > 0 ) { //if( MYsettings->GetIap() > 0 )
    MYdebug->Output8(_L8("I"), _L8("SetupConnectionL"), _L8("if2"));
    iConnectionSetupDone = EFalse;
    TCommDbConnPref connectPref;
    // Setup preferences
    connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    // Sets the CommDb ID of the IAP to use for this connection
    connectPref.SetIapId(iAccesspoint); //MYsettings->GetIap());

    //open socket server and start the connection
    TInt iConnExist;
    iConnExist = iSocketServ.Connect();
    MYdebug->Output8(_L8("I"), _L8("SetupConnectionL_iConnExist"), iConnExist);

    if(iConnExist==0){

    iConnExist=iConnection.Open(iSocketServ);
    MYdebug->Output8(_L8("I"), _L8("SetupConnectionL_iConnExist2"), iConnExist);
    if(iConnExist==0){
    // iConnection.CancelAllInterfaceNotification();

    //User::LeaveIfError(iConnExist=iConnection.Start(connectPref));
    iConnExist=iConnection.Start(connectPref);

    MYdebug->Output8(_L8("I"), _L8("SetupConnectionL_iConnExist3"), iConnExist);
    if(iConnExist==0){
    //set the sessions connection info
    RStringPool strPool = iSession.StringPool();
    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();

    //to use our socket server and connection
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ,
    RHTTPSession::GetTable() ), THTTPHdrVal (iSocketServ.Handle()) );

    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection,
    RHTTPSession::GetTable() ),
    THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection))) );
    }else
    if(iConnExist==-4303){
    MYdebug->Output8(_L8("E"), _L8("SetupConnectionL"), _L8("wrong accespoint re select it"));
    iAccesspoint = 0;
    MYconf->SetAccesspoint(iAccesspoint);
    goto SelectIAP;
    }else{
    iConnectionSetupDone=EFalse;
    MYdebug->Output8(_L8("E"), _L8("SetupConnectionL"), _L8("cannot start connection"));
    return;
    }
    }else{
    iConnectionSetupDone=EFalse;
    MYdebug->Output8(_L8("E"), _L8("SetupConnectionL"), _L8("cantOpenSocketServer"));
    return;
    }
    }else{
    MYdebug->Output8(_L8("E"), _L8("SetupConnectionL"), _L8("cantConnectSocketServer"));
    iConnectionSetupDone=EFalse;
    return;
    }
    iConnectionSetupDone=ETrue;
    MYapp->ConnectionDone();
    }//if
    //iConnectionSetupDone=ETrue;
    MYdebug->Output8(_L8("I"), _L8("SetupConnectionL"), _L8("finished"));

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,693

    Re: GPRS connection stays active when using Explicit connection

    The code for what?
    Note that the original question is 4.5 years old, and it is the only question of Russ_world. And you have not answered it, by the way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×