RConnection Start opens internet connection?

Login to reply to this topic.
Mon, 2008-05-26 15:51
Joined: 2008-04-03
Forum posts: 5

I want to make an automatic connection to the internet from a mobile phone, without having to select a IAP during executation of my application. I use the following code:

iSocketServ.Connect();

iConnection.Open(iSocketServ));

TInt iapID = 7;
TCommDbConnPref prefs;
prefs.SetIapId(iapID);
prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);

iConnection.Start(prefs);

iListenSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp, iConnection);

err = iListenSocket.Bind(inetAddr);

However, the call to the function bind returns -1.

Only when I first make an explicit connection to the internet by means of another application, which explicitly asks me to select an IAP, the bind function works fine.
But, as I understood, the call to iConnection.iStart(prefs) is supposed to make an internet connection itself.
Why doesn´t that work?


Tue, 2008-05-27 20:01
Joined: 2005-04-13
Forum posts: 120
Re: RConnection Start opens internet connection?

u can check the return code iConnection.Start. Use the async version of the call if possible to get better results.


Jupitar

Wed, 2008-05-28 09:29
Joined: 2008-04-03
Forum posts: 5
Re: RConnection Start opens internet connection?

I actually make the call as follows:

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

Mon, 2008-06-02 13:28
Joined: 2007-01-17
Forum posts: 96
Re: RConnection Start opens internet connection?

If the IAP value is invalid{note that you have used a static value 7 whcih might be invalid} then the prompt is opened automatically else it works just fine


Shashi Kiran G M

Mon, 2008-06-02 13:32
Joined: 2007-01-17
Forum posts: 96
Re: RConnection Start opens internet connection?

Use the following code to Choose Access Point . You store this in a file and retreive it for Use later

RSocketServ sockserver;
                         sockserver.Connect();
                         RConnection connection;
                         connection.Open(sockserver);
                         TInt err = connection.Start();
                         if(err == KErrCancel)
                                 {
                                 //Do Nothing
                                 }
                         else
                                 {
                                TUint actv;
                                connection.EnumerateConnections(actv);
                                TConnectionInfoBuf infBuf;
                                err = connection.GetConnectionInfo(actv, infBuf);
                               
                                TUint iapId = infBuf().iIapId;
                                }
                         connection.Stop();
                        connection.Close();
                        sockserver.Close();

Hope this helped


Shashi Kiran G M

  • Login to reply to this topic.