| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| 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? |
|
#2
| |||
| |||
| 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. |
|
#3
| |||
| |||
| 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. |
|
#4
| |||
| |||
| From the sounds of it, this is a problem with the address (inetAddr). What value are you using/how are you constructing it? |
|
#5
| |||
| |||
| 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. |
|
#6
| |||
| |||
| 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. |
|
#7
| |||
| |||
| Ok, I´ll try that as well. Thank you both very much.=20 I´ll let you know if if worked. Cheers. |
|
#8
| |||
| |||
| 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. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.