0

I'm using this sample code by CodeProject to connect to GPRS in a Windows Mobile in C#.

I tried the code and it works fine. However, sometimes I get a message saying "ConnectionLinkFailed" and I can't connect to GPRS.

I must wait some time in order to being able to connect again. Rebooting doesn't solve the problem either.

Does anyone knows how to avoid this exception?

Thanks for any help!

Ignacio Gómez
  • 1,587
  • 4
  • 23
  • 41

1 Answers1

1

The MSDN site only states:

CONNMGR_STATUS_CONNECTIONLINKFAILED The connection link was prematurely disconnected.

There is no further description. I assume you have a problem with your provider. Beside from that, I do not rely on Connection Manager (CM) connections. Soemtimes it states a connection is available, but it is not in real as CM uses a cached information.

Normally, for getting a connection, you only have to issue a http request. CM will choose the right connection. Usa of CM API is only usefull if you need to switch between different connections with same destination network. But this i normally not the case, as you will have normally only a WiFi and one GPRS connection to internet and WiFi is selected prior to GPRS (due to costs).

What is the scenario that makes you think you have to use CM?

josef
  • 5,951
  • 1
  • 13
  • 24
  • I'm using to establish a socket connection between a handheld and the server. I think that before trying to make this connection I must be connected to internet, don't I? – Ignacio Gómez Dec 20 '12 at 12:33
  • Yes, before you can use a socket, there must be an internet connection. But CM will establish the connection automatically. And as said, CM may state a working connection although it is not working. So a better approach is to just open a http request to a known adress, additionally use ping to verfify connection and then start your socket connection. If the socket operation is a http request, you just only use that to signal CM to open a connection (if it is not yet really open). – josef Dec 21 '12 at 13:15
  • I made what you told me and it's far simpler. Thanks – Ignacio Gómez Dec 27 '12 at 16:50
  • Fine. Have a happy new year – josef Dec 27 '12 at 18:21