3.1.4.3 Disconnecting Gracefully

Higher layers that will no longer communicate over an established connection SHOULD cause the DirectPlay 8 Protocol to send a reliable DFRAME message that has the PACKET_CONTROL_END_STREAM flag set. To avoid data loss for the upper layer, this message SHOULD NOT be sent until all messages that were previously queued by the higher layer have been sent. This PACKET_CONTROL_END_STREAM message SHOULD be a separate packet that contains no payload; however, it can be the final queued data packet.

If the connection was established with signing, the DFRAME MUST be signed appropriately, as described in section 3.1.4.4.

Implementations MUST NOT send any additional DFRAMEs after sending a packet that has the PACKET_CONTROL_END_STREAM flag set to other than retries. It MUST be prepared to continue receiving and acknowledging packets until the remote partner sends its own PACKET_CONTROL_END_STREAM packet.

Upon receipt of a packet with the PACKET_CONTROL_END_STREAM flag set, implementations SHOULD begin the process of disconnecting gracefully, including sending a final DFRAME with the PACKET_CONTROL_END_STREAM flag set, if this has not already been sent by the local system. Receivers MUST NOT expect additional DFRAMEs with sequence IDs beyond the one on the PACKET_CONTROL_END_STREAM packet, and SHOULD ignore all packets that have such sequence numbers.

When the DFRAME that contains a sender's PACKET_CONTROL_END_STREAM indicator has been acknowledged, and the remote partner's own PACKET_CONTROL_END_STREAM has been received and the acknowledgment (ACK) sent, the connection SHOULD be considered terminated.

Higher layers can also perform a hard disconnect, as described in section 3.1.4.5.