@@ -1574,27 +1574,27 @@ class stream
15741574 //
15751575 // --------------------------------------------------------------------------
15761576
1577- /* * Send a websocket close control frame .
1577+ /* * Perform the WebSocket closing handshake and close the underlying stream .
15781578
1579- This function is used to send a
1580- <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a>,
1581- which begins the websocket closing handshake. The session ends when
1582- both ends of the connection have sent and received a close frame.
1579+ This function sends a
1580+ <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a>
1581+ to begin the WebSocket closing handshake and waits for a corresponding
1582+ close frame in response. Once received, it calls @ref teardown
1583+ to gracefully shut down the underlying stream.
15831584
1584- The call blocks until one of the following conditions is true:
1585+ After beginning the closing handshake, the program should not write
1586+ further message data, pings, or pongs. However, it can still read
1587+ incoming message data. A read returning @ref error::closed indicates a
1588+ successful connection closure.
15851589
1586- @li The close frame is written.
1590+ The call blocks until one of the following conditions is true:
15871591
1592+ @li The closing handshake completes, and @ref teardown finishes.
15881593 @li An error occurs.
15891594
15901595 The algorithm, known as a <em>composed operation</em>, is implemented
15911596 in terms of calls to the next layer's `write_some` function.
15921597
1593- After beginning the closing handshake, the program should not write
1594- further message data, pings, or pongs. Instead, the program should
1595- continue reading message data until an error occurs. A read returning
1596- @ref error::closed indicates a successful connection closure.
1597-
15981598 @param cr The reason for the close.
15991599 If the close reason specifies a close code other than
16001600 @ref beast::websocket::close_code::none, the close frame is
@@ -1609,27 +1609,27 @@ class stream
16091609 void
16101610 close (close_reason const & cr);
16111611
1612- /* * Send a websocket close control frame .
1612+ /* * Perform the WebSocket closing handshake and close the underlying stream .
16131613
1614- This function is used to send a
1615- <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a>,
1616- which begins the websocket closing handshake. The session ends when
1617- both ends of the connection have sent and received a close frame.
1614+ This function sends a
1615+ <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a>
1616+ to begin the WebSocket closing handshake and waits for a corresponding
1617+ close frame in response. Once received, it calls @ref teardown
1618+ to gracefully shut down the underlying stream.
16181619
1619- The call blocks until one of the following conditions is true:
1620+ After beginning the closing handshake, the program should not write
1621+ further message data, pings, or pongs. However, it can still read
1622+ incoming message data. A read returning @ref error::closed indicates a
1623+ successful connection closure.
16201624
1621- @li The close frame is written.
1625+ The call blocks until one of the following conditions is true:
16221626
1627+ @li The closing handshake completes, and @ref teardown finishes.
16231628 @li An error occurs.
16241629
16251630 The algorithm, known as a <em>composed operation</em>, is implemented
16261631 in terms of calls to the next layer's `write_some` function.
16271632
1628- After beginning the closing handshake, the program should not write
1629- further message data, pings, or pongs. Instead, the program should
1630- continue reading message data until an error occurs. A read returning
1631- @ref error::closed indicates a successful connection closure.
1632-
16331633 @param cr The reason for the close.
16341634 If the close reason specifies a close code other than
16351635 @ref beast::websocket::close_code::none, the close frame is
@@ -1644,30 +1644,34 @@ class stream
16441644 void
16451645 close (close_reason const & cr, error_code& ec);
16461646
1647- /* * Send a websocket close control frame asynchronously.
1647+ /* * Perform the WebSocket closing handshake asynchronously and close
1648+ the underlying stream.
16481649
1649- This function is used to asynchronously send a
1650- <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a>,
1651- which begins the websocket closing handshake. The session ends when
1652- both ends of the connection have sent and received a close frame.
1650+ This function sends a
1651+ <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a>
1652+ to begin the WebSocket closing handshake and waits for a corresponding
1653+ close frame in response. Once received, it calls @ref async_teardown
1654+ to gracefully shut down the underlying stream asynchronously.
1655+
1656+ After beginning the closing handshake, the program should not write
1657+ further message data, pings, or pongs. However, it can still read
1658+ incoming message data. A read returning @ref error::closed indicates a
1659+ successful connection closure.
16531660
16541661 This call always returns immediately. The asynchronous operation
16551662 will continue until one of the following conditions is true:
16561663
1657- @li The close frame finishes sending.
1658-
1664+ @li The closing handshake completes, and @ref async_teardown finishes.
16591665 @li An error occurs.
16601666
1667+ If a timeout occurs, @ref close_socket will be called to close the
1668+ underlying stream.
1669+
16611670 The algorithm, known as a <em>composed asynchronous operation</em>,
16621671 is implemented in terms of calls to the next layer's `async_write_some`
16631672 function. No other operations except for message reading operations
16641673 should be initiated on the stream after a close operation is started.
16651674
1666- After beginning the closing handshake, the program should not write
1667- further message data, pings, or pongs. Instead, the program should
1668- continue reading message data until an error occurs. A read returning
1669- @ref error::closed indicates a successful connection closure.
1670-
16711675 @param cr The reason for the close.
16721676 If the close reason specifies a close code other than
16731677 @ref beast::websocket::close_code::none, the close frame is
@@ -1704,7 +1708,7 @@ class stream
17041708
17051709 `terminal` cancellation succeeds when supported by the underlying stream.
17061710
1707- @note `terminal` cancellation will may close the underlying socket.
1711+ @note `terminal` cancellation may close the underlying socket.
17081712
17091713 @see
17101714 @li <a href="https://tools.ietf.org/html/rfc6455#section-7.1.2">Websocket Closing Handshake (RFC6455)</a>
0 commit comments