Boost.Asio demptor break closes connection?

What exactly does the destructor boost::asio::ip::tcp::socketdo? I can’t say even after clearing the Boost documents and source code if I need to use

socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both);
socket->close();

before calling

delete socket;

Do I need to close the socket manually or will the handle handle this?

+4
source share
3 answers

When a socket is destroyed, it will be closed as-if through socket.close(ec)during socket destruction.

/, socket, basic_io_object. basic_io_object , destroy() - -, implementation_type, -. destroy() , SocketService, . a , b implementation_type :

a.destroy(b):

[...] , a.close(b, ec).

a.close(b, ec):

a.is_open() , . error::operation_aborted.

     

post: !a.is_open(b).

+5
+3

shutdown(). close(): " () ".

, , - shutdown().

+2

Source: https://habr.com/ru/post/1656484/


All Articles