RConnection::Start opens internet connection?

This is a discussion on RConnection::Start opens internet connection? within the Symbian forums in Other Technologies category; 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:=20 bq. =09iSocketServ.Connect(); \\=09 iConnection.Open(iSocketServ)); \\=09 T= Int iapID =3D 7; \\=09 TCommDbConnPref prefs; \\=09 prefs.SetIapId(iapID); = \\=09 prefs.SetDialogPreference(ECommDbDialogPrefDoNotPr ompt); \\=09 iConne= ction.Start(prefs); \\=09 iListenSocket.Open(iSocketServ, KAfInet, KSockStr= eam, KProtocolInetTcp, iConnection); \\=09 err =3D iListenSocket.Bind(inetA= ddr); However, the call to the function bind returns -1.=20 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 ...

Go Back   Application Development Forum > Other Technologies > Symbian

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 05-26-2008, 10:59 AM
mach
Guest
 
Default RConnection::Start opens internet connection?

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:=20
bq. =09iSocketServ.Connect(); \\=09 iConnection.Open(iSocketServ)); \\=09 T=
Int iapID =3D 7; \\=09 TCommDbConnPref prefs; \\=09 prefs.SetIapId(iapID); =
\\=09 prefs.SetDialogPreference(ECommDbDialogPrefDoNotPr ompt); \\=09 iConne=
ction.Start(prefs); \\=09 iListenSocket.Open(iSocketServ, KAfInet, KSockStr=
eam, KProtocolInetTcp, iConnection); \\=09 err =3D iListenSocket.Bind(inetA=
ddr);

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

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.=20
But, as I understood, the call to iConnection.iStart(prefs) is supposed to =
make an internet connection itself.=20
Why doesn´t that work?
Reply With Quote
  #2  
Old 05-26-2008, 11:34 AM
maxpayne
Guest
 
Default Re: RConnection::Start opens internet connection?

Hi [~mach],

Have you actually tested what RConnection::Start actually returns (i.e. iSt=
atus.Int() in RunL if you are calling RConnection::Start asynchronously or =
just the return value of RConnection::Start if calling synchronously)? Beca=
use starting the connection (IAP 7) may have failed?

Cheers.
Reply With Quote
  #3  
Old 05-26-2008, 12:19 PM
mach
Guest
 
Default Re: RConnection::Start opens internet connection?

Yes, it always returns KErrNone.=20
I actuallly do the following in my code (which never leaves):=20

bq. User::LeaveIfError(iConnection.Start(prefs));
bq.
Reply With Quote
  #4  
Old 05-26-2008, 01:35 PM
paul_todd
Guest
 
Default Re: RConnection::Start opens internet connection?

From the sounds of it, this is a problem with the address (inetAddr).

What value are you using/how are you constructing it?
Reply With Quote
  #5  
Old 05-26-2008, 03:18 PM
mach
Guest
 
Default Re: RConnection::Start opens internet connection?

Ah... This could be a clue...=20
Right now I am at home, and I cannot check my code.=20
But in another thread "find host IP address" that I put here today, I ask a=
bout how to find out the IP address of the host. I use two methods, one of =
which returns a "192" type of address, and another method which returns a "=
169" type of address.=20

The "169" type of address is returned by a method which uses TSoInetInterfa=
ceInfo and TSoInetIfQuery, whereas the "192" method uses RHostResolver.=20

Could it be that when I use an "169" address in the call to bind, it fails,=
whereas with a "192" address it would=20
function allright? (I´m relatively new with sockets, so I am not sure=
what these different addresses mean).=20

I´ll check this out wednesday, but I have the feeling this might very=
well be the answer.=20

Many thanks.
Reply With Quote
  #6  
Old 05-26-2008, 04:20 PM
maxpayne
Guest
 
Default Re: RConnection::Start opens internet connection?

Hi [~mach],


If its a problem with Bind, I suggest using [SetLocalPort|http://www.symbia=
n.com/developer/techlib/v9.3docs/doc_source/reference/reference-cpp/ESOCK/R=
SocketClass.html#%3a%3aRSocket%3a%3aSetLocalPort%2 8%29|SetLocalPort] on the=
listening socket, that will hopefully solve your problem. SetLocalPort req=
uires just the port name, no address but will achieve the same thing as Bin=
d would anyway.

Hope that helps.
Reply With Quote
  #7  
Old 05-26-2008, 05:43 PM
mach
Guest
 
Default Re: RConnection::Start opens internet connection?

Ok, I´ll try that as well. Thank you both very much.=20
I´ll let you know if if worked. Cheers.
Reply With Quote
  #8  
Old 05-28-2008, 05:22 AM
mach
Guest
 
Default Re: RConnection::Start opens internet connection?

OK. You were both right.=20
If I bind to an "192." type address it works. And if use SetLocalPort it wo=
rks okay as well.
Thanks very much.=20

The only thing that still makes me curious is why the one method (using TSo=
InetInterfaceInfo and looping around it, as explained in the other thread) =
only gives a 169 type address, whereas with RHostResolver I can get the rea=
l 192 address. Why would that be?

Is there any clear introductory information on the internet about the meani=
ng of the value (169 / 192) of an=20
IP address. Wikipedia is not good enough.=20

Many thanks anyway for your help.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 09:01 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.