×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    Non-blocking RConnection

    Is there any code example in how to implement non-blocking data connection setup with RConnection?

    I use an HTTP Engine that uses synchronous RConnection methods, but some of the methods block the application for quite some time. Rendering it unresponsive.
    For example, the call to

    User::LeaveIfError(iConnection.Start(connectPref));

    often takes over 30 seconds to return in my office when I select the WAP APN for Telefonica, or the Vodafone Live for Vodafone.
    Most users patience threshold when the app gets unresponsive is below 10 seconds.

    I would like to experiment with the async methods for RConnection, but can't find any example.
    ----------------------------------------------
    Every journey starts with a small step.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,734

    Re: Non-blocking RConnection

    Obviously you need an active object for that.
    Then code like
    Code:
    User::LeaveIfError(iConnection.Start());
    User::LeaveIfError(iSocket.Open(iSocketServer,KAfXy,KSockStream,KInetProtocolTcp,iConnection));
    iSocket.Connect(iStatus,iAddress);
    iState=EConnecting;
    SetActive();
    will become
    Code:
    iConnection.Start(iStatus);
    iState=EStarting;
    SetActive();
    plus
    Code:
    RunL()
    {
        if(iStatus==KErrNone)
        {
            switch(iState)
            {
            case EStarting:
                User::LeaveIfError(iSocket.Open(iSocketServer,KAfXy,KSockStream,KInetProtocolTcp,iConnection));
                iSocket.Connect(iStatus,iAddress);
                iState=EConnecting;
                SetActive();
                break;
    hopefully you see the pattern.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    Re: Non-blocking RConnection

    Converting from sync to async for RConnection, everything works fine except for the following:

    Code:
            if(iSelectedIap != KInvalidIAPvalue)
            	{
    			// IAP Selected
            	static_cast<CMyAppUi*>(CEikonEnv::Static()->AppUi())->iSelectedIap = iSelectedIap;
            	iObserver.HTTPEvent(MHTTPObserver::EConnecting);
            	
    			// Open socket server and start the connection
    			User::LeaveIfError(iSocketServ.Connect());
    			User::LeaveIfError(iConnection.Open(iSocketServ));
    			// Now we have the iap Id. Use it to connect for the connection
    			TCommDbConnPref connectPref;
    			// Setup preferences 
    			connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    			// Sets the CommDb ID of the IAP to use for this connection
    			connectPref.SetIapId(iSelectedIap);
    			// Start connection
    			iState = EHTTPEngine_Idle;
    			iConnection.Start(connectPref, iStatus);
    			SetActive();
            	}
    The red line seems to ignore the first argument (connectPref). Even though it is configured with ECommDbDialogPrefDoNotPrompt, the IAP selection dialog is displayed. This IAP selection has not much effect. If discarded, the connection proceeds OK using the IAP already selected before.

    This was working OK before, when the sync version of iConnection.Start(connectPref) was used.
    I have been looking at several examples (most of the on ALR), but have not found a cause for this.
    Anyone knows?
    ----------------------------------------------
    Every journey starts with a small step.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,734

    Re: Non-blocking RConnection

    That is an IPC rule: every reference arguments you pass to an asynchronous service provider have to remain available and intact during the whole service period of that request. So connectPref has to become a member variable.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    Re: Non-blocking RConnection

    I have made TCommDbConnPref connectPref a class-level variable, but I get the same result. "connectPref" is not touched anywhere after passing it to iConnection.Start()

    There is some issue with the debugger (on device) that shows "connectPref" as "invalid reference" (0x). I have seen at least one post discussing this, but in my case, the code works and iSelectedIap is used if I discard the IAP selection dialog that appears when iConnection.Start() is called
    ----------------------------------------------
    Every journey starts with a small step.

  6. #6
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    Re: Non-blocking RConnection

    I have been trying quite a few things, but can't get this to work properly.
    The code in
    http://www.forum.nokia.com/info/sw.n...I_Example.html
    is actually similar to mine, but does not work on pre-3rd Edition FP2. So I kept the code that I put on a previous post. Still, I can't get:

    iConnection.Start(iCommDbConnPref, iStatus);

    to follow iCommDbConnPref the first time it is used in the app. When this instruction is executed, the app shows an APN selection dialog regarless of iCommDbConnPref.
    It works OK on second and further time, when the same line is executed. And, there has not been any modification of iCommDbConnPref whatsoever on those times.

    Any clue what I may be doing wrong?
    ----------------------------------------------
    Every journey starts with a small step.

Similar Threads

  1. RConnection and RHTTP session under V9
    By StephBel in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2010-01-04, 18:59
  2. BUG?? Blocking read() calls on InputStreams
    By kbateman in forum Mobile Java Tools & SDKs
    Replies: 8
    Last Post: 2009-01-03, 18:07
  3. simple RConnection question
    By rtrnokia in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2007-11-21, 07:59
  4. "problem with Non blocking socket creation"
    By pankaj-jataayu in forum Symbian
    Replies: 2
    Last Post: 2005-05-17, 13:17
  5. Inputstream read method is blocking
    By gnhansen in forum Bluetooth Technology
    Replies: 0
    Last Post: 2004-09-29, 14:44

Posting Permissions

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