How to Close TCP connection properly before system goes to Standby/Hibernate ?

Hi All,

Here is a problem regarding TDI and Power Management.

Our requirement is to close all the TCP connections before we go in to low power state.

When I receive a IRP_MN_SETPOWER, I am calling TdiBuildDisconnect with TDI_DISCONNECT_RELEASE flag and calling IoCallDriver. This request is completing immediately and system is going in to Suspend state immediately. But we are seeing that the connection is still not closed on the remote side. What is also observed is, when the system comes out of standby, then a FIN is going across.

i.e the connection is terminating after we come out of standby.
What we need to do to close the TCP connection before we enter in to Standby?

Thanks.

TDI_DISCONNECT_RELEASE initiates a graceful disconnect that will require
communication from the remote end to finalize the disconnect. This could
take quite a while.

TDI_DISCONNECT_ABORT will immediately tear down the connection.

Thomas F. Divine
http://www.pcausa.com

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-272022-
xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Wednesday, December 06, 2006 2:40 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to Close TCP connection properly before system goes
to Standby/Hibernate ?

Hi All,

Here is a problem regarding TDI and Power Management.

Our requirement is to close all the TCP connections before we go in to low
power state.

When I receive a IRP_MN_SETPOWER, I am calling TdiBuildDisconnect with
TDI_DISCONNECT_RELEASE flag and calling IoCallDriver. This request is
completing immediately and system is going in to Suspend state
immediately. But we are seeing that the connection is still not closed on
the remote side. What is also observed is, when the system comes out of
standby, then a FIN is going across.

i.e the connection is terminating after we come out of standby.
What we need to do to close the TCP connection before we enter in to
Standby?

Thanks.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Eventhough the TDI documentation would lead you to believe that this
capability (graceful, syncronized disconnect) is possible, I recall that the
actual behavior is transport specific. You may have better results if you
handle this syncronization ‘in-band’ by having an explicit termination
exchange on the TCP connection itself (though even that might not solve the
problem with the FIN waking the box up.)

I have not tried this but you might also look into the possiblity that the
AddressObject that the ConnectionObject is associated with will get a
ClientEventDisconnect() *after* the connection has been completely (as
opposed to half) closed. The problem with this, of course, is that with
lost packets, failures of other sorts, etc. it might take a while for a
timeout to figure out the connection should be abandoned and thus delay your
power-down processing.

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.com
Sent: Wednesday, December 06, 2006 2:40 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to Close TCP connection properly before system goes to
Standby/Hibernate ?

Hi All,

Here is a problem regarding TDI and Power Management.

Our requirement is to close all the TCP connections before we go in to low
power state.

When I receive a IRP_MN_SETPOWER, I am calling TdiBuildDisconnect with
TDI_DISCONNECT_RELEASE flag and calling IoCallDriver. This request is
completing immediately and system is going in to Suspend state immediately.
But we are seeing that the connection is still not closed on the remote
side. What is also observed is, when the system comes out of standby, then a
FIN is going across.

i.e the connection is terminating after we come out of standby.
What we need to do to close the TCP connection before we enter in to
Standby?

Thanks.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> TDI_DISCONNECT_RELEASE initiates a graceful disconnect that will require

communication from the remote end to finalize the disconnect. This could
take quite a while.

TDI_DISCONNECT_RELEASE sends a FIN.

Also you must also receive the ClientEventDisconnect indication, which is the
incoming FIN.

Only after this the connection can be considered gracefully closed.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> I have not tried this but you might also look into the possiblity that the

AddressObject that the ConnectionObject is associated with will get a
ClientEventDisconnect() *after* the connection has been completely (as
opposed to half) closed.

In my experience (wrote the kernel sockets library in 2001),
ClientEventDisconnect is called on incoming FIN, regardless of the fate of your
outgoing FIN.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com