4.2.2 Disconnecting a Connection
The initiator is responsible for disconnecting the connection when the connection is complete, even if the connection was denied by the acceptor.
The initiator begins the disconnect sequence for a connection by creating a MESSAGE_PACKET structure with the MsgTag field set to MTAG_DISCONNECT (0x00000001), the dwConnectionId field set to the identifier of the connection being disconnected (0x00000001), and the dwUserMsgType field set to CONNTYPE_PARTNERTM_PROPAGATE (0x00000101).
The MESSAGE_PACKET structure is as follows.
|
Field |
Value |
Description |
|---|---|---|
|
MsgTag |
0x00000001 |
MTAG_DISCONNECT |
|
fIsMaster |
0x00000001 |
1 |
|
dwConnectionId |
0x00000001 |
1 |
|
dwUserMsgType |
0x00000101 |
CONNTYPE_PARTNERTM_PROPAGATE |
|
dwcbVarLenData |
0x00000000 |
0 |
|
dwReserved1 |
0xcd64cd64 |
dwReserved1: 0xcd64cd64 |
The initiator packages this MESSAGE_PACKET into a boxcar and sends it to the acceptor over the underlying transports protocol session as specified in [MS-CMPO].
When the acceptor receives the disconnect request, the acceptor begins the process of cleaning up any connection-specific resources. After this process is complete, the acceptor creates a MESSAGE_PACKET structure with the MsgTag field set to MTAG_DISCONNECTED (0x00000002), the dwConnectionId field set to the identifier of the connection that was just disconnected (0x00000001), and the dwUserMsgType field set to zero (0x00000000). The complete MESSAGE_PACKET structure is as follows.
|
Field |
Value |
Description |
|---|---|---|
|
MsgTag |
0x00000002 |
MTAG_DISCONNECTED |
|
fIsMaster |
0x00000000 |
0 |
|
dwConnectionId |
0x00000001 |
1 |
|
dwUserMsgType |
0x00000000 |
dwUserMsgType: 0 |
|
dwcbVarLenData |
0x00000000 |
0 |
|
dwReserved1 |
0xcd64cd64 |
dwReserved1: 0xcd64cd64 |
When the initiator receives the disconnected message, the initiator then cleans up any connection-specific resources and reclaims the connection identifier for future use.