Closing a Connection Endpoint
The following figure shows how a kernel-mode client closes a connection endpoint.
After an endpoint-to-endpoint connection has been disconnected, as already described in Disconnecting an Endpoint-to-Endpoint Connection, a client can close the connection endpoint.
When a client no longer has any use for an open connection endpoint, it must close that connection endpoint as follows:
Pass the file object pointer returned by ObReferenceObjectByHandle to ObDereferenceObject.
Pass the file handle that was returned by ZwCreateFile when the connection endpoint was opened to ZwClose.
Then, the I/O manager submits IRPs to the transport's TdiDispatchCleanupand, subsequently, TdiDispatchCloseroutines.
These transport routines immediately close the connection endpoint and free all associated transport driver resources. TdiDispatchCleanup also terminates any active connection involved with the endpoint by sending a disconnect notification to the corresponding remote-node transport.
As the preceding sentence implies, it is unnecessary for a TDI client to disassociate the connection endpoint from its associated transport address before making a close-connection-endpoint request. If necessary, the underlying transport driver simulates the effects of a disassociation.
However, a client can explicitly disassociate a connection endpoint from an open transport address before closing the connection endpoint by making a TDI_DISSOCIATE_ADDRESSrequest to the transport, set up with TdiBuildDisassociateAddress.
For example, a client might make a disassociate-address request and reassociate the open connection endpoint with another open transport address.
Note The TDI feature is deprecated and will be removed in future versions of Microsoft Windows. Depending on how you use TDI, use either the Winsock Kernel (WSK) or Windows Filtering Platform (WFP). For more information about WFP and WSK, see Windows Filtering Platform and Winsock Kernel. For a Windows Core Networking blog entry about WSK and TDI, see Introduction to Winsock Kernel (WSK).