Connection Manager - Disconnect

  • Thread starter Thread starter Tomer
  • Start date Start date
T

Tomer

Hi,

I've use the connection manager to establish a GPRS connection, having that worked, I've tried to disconnect using these commands:

CM.Disconnect(CM.Handle);

CM.Disconnect();

RasHangUp(CM.Handle);

// RasHangUp is defined like this
[DllImport("Coredll.dll")]

public extern static uint RasHangUp(IntPtr hrasconn);

None of them seems to work.

Any help would be great!

Tomer.
 
Connection Manager Disconnect method let's CM to know that it's ok to disconnect, but does not actually hang up in WM2003.
RasHangup will not work with CM handle.
Suposedly you don't want to diconnect as the connected state does not equal traffic and traffic is what you are paying for. Think of it as conected but dormant

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi,

I've use the connection manager to establish a GPRS connection, having that worked, I've tried to disconnect using these commands:

CM.Disconnect(CM.Handle);

CM.Disconnect();

RasHangUp(CM.Handle);

// RasHangUp is defined like this
[DllImport("Coredll.dll")]

public extern static uint RasHangUp(IntPtr hrasconn);

None of them seems to work.

Any help would be great!

Tomer.
 
You can use RasHangUp(), but you need the handle to the RAS connection, not
the Connection Manager handle. You can use RasEnumConnections() to enumerate
active connections and find that handle. I've not done it from managed code,
but I use this method from eVC++ to do exactly what you are trying to do.

I would try calling CM.Disconnect first, wait a few seconds, then call
RasEnumConnections() to see if the RAS connection is still around.
Sometimes, Connection Manager will drop the connection. It depends on what
else has used that connection and (I think) whether or not the "bCache" flag
has been set on previous calls to ConnMgrReleaseConnection().

Hope that helps,
Darren

Hi,

I've use the connection manager to establish a GPRS connection, having that
worked, I've tried to disconnect using these commands:

CM.Disconnect(CM.Handle);
CM.Disconnect();
RasHangUp(CM.Handle);
// RasHangUp is defined like this
[DllImport("Coredll.dll")]
public extern static uint RasHangUp(IntPtr hrasconn);
None of them seems to work.
Any help would be great!
Tomer.
 
Hi,

at least in Germany you often pay for the online time and not the traffic.
So this is not really satisfying.

I experimented a lot using the Connection Manager and made the following
observations:

* Using the System.Net.Sockets TcpClient .NETCF does not automatically
connect to the Internet. So in this case one must P/Invoke the Connection
Manager anyway. This has the advantage that ConnMgrReleaseConnection orderly
disconnects just as expected.

* Using the System.Net HttpWebRequest causes .NETCF to automatically connect
to the Internet using the Connection Manager. However, using P/Invoke the
Connection Manager to manually connect and disconnect in this scenario no
longer works!

* If I used the HttpWebRequest it disconnects anyway after 10 Minutes.

* Although documented differently with the Pocket PC 2003 SDK, the second
parameter to ConnMgrReleaseConnection is not a BOOL but a LONG that provides
the connection cache time in seconds (at least with WM2003). The SmartPhone
2003 SDK has the correct documentation for this.

IMHO the .NET HttpWebRequest either just does not call
ConnMgrReleaseConnection at all (which I would consider a real bug), or it
calls ConnMgrReleaseConnection with a 10 minutes caching timeout. In either
case not very helpful.

Cheers,

Andreas


Connection Manager Disconnect method let's CM to know that it's ok to
disconnect, but does not actually hang up in WM2003.
RasHangup will not work with CM handle.
Suposedly you don't want to diconnect as the connected state does not equal
traffic and traffic is what you are paying for. Think of it as conected but
dormant

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi,

I've use the connection manager to establish a GPRS connection, having that
worked, I've tried to disconnect using these commands:

CM.Disconnect(CM.Handle);
CM.Disconnect();
RasHangUp(CM.Handle);
// RasHangUp is defined like this
[DllImport("Coredll.dll")]
public extern static uint RasHangUp(IntPtr hrasconn);
None of them seems to work.
Any help would be great!
Tomer.
 
Hi Andreas,

I had a few questions about your setup. Can you give me more information/
try out a few more things:

1. Are you using smartphone or pocket PC? Are there differences in behavior
between the two platforms?
2. Are you using RTM, sp1 or sp2 of NETCF?
3. Do you set the timeout property on the HttpWebRequest class?
4. Does your http request succeed or fail?
5. Can you do a GC.Collect() after you do a HttpWebRequest.Close(); to make
GC do a finalization. Does this change the behavior in any way?

To answer your question, we are not aware of any bugs in this area. We
should be calling ConnMgrReleaseConnection after finishing the request.

Thanks,
Sandy

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi,

Sandeep Prabhakar said:
1. Are you using smartphone or pocket PC? Are there differences in
behavior
between the two platforms?

I am using various Pocket PC 2003 devices. I never tried it on a Smartphone
so far.
2. Are you using RTM, sp1 or sp2 of NETCF?

I always require and use .NETCF SP2
3. Do you set the timeout property on the HttpWebRequest class?

Yes, the Timeout property is set to 2 Minutes.
4. Does your http request succeed or fail?

It succeeds.
5. Can you do a GC.Collect() after you do a HttpWebRequest.Close(); to
make
GC do a finalization. Does this change the behavior in any way?

I just tried that. It didn't change anything.
To answer your question, we are not aware of any bugs in this area. We
should be calling ConnMgrReleaseConnection after finishing the request.

Thanks,
Sandy

Thank you very much for your help.

Please allow a few more questions:

Which value do you pass for the bCache (or lCache) parameter to
ConnMgrReleaseConnection?

In the Pocket-PC 2003 SDK ConnMgrReleaseConnection is documented as
HRESULT WINAPI ConnMgrReleaseConnection(HANDLE hConnection, BOOL bCache );
although in the included C++ header "connmgr.h" file it is declared as
HRESULT WINAPI ConnMgrReleaseConnection(HANDLE hConnection, LONG lCache);
I guess the latter is the right one, is it?

Cheers,

Andreas
 
Andreas Selle said:
Hi,

Newsbeitrag
In the Pocket-PC 2003 SDK ConnMgrReleaseConnection is documented as
HRESULT WINAPI ConnMgrReleaseConnection(HANDLE hConnection, BOOL bCache );
although in the included C++ header "connmgr.h" file it is declared as
HRESULT WINAPI ConnMgrReleaseConnection(HANDLE hConnection, LONG lCache);
I guess the latter is the right one, is it?

It doesn't really matter - same type
 
Back
Top