Boost.Asio socket destructor closes connection?

后端 未结 3 538
南笙
南笙 2021-01-11 17:37

What exactly does the destructor of boost::asio::ip::tcp::socket do? I can\'t tell, even after scouring Boost docs and source code, if I need to use

         


        
3条回答
  •  鱼传尺愫
    2021-01-11 17:52

    The answers have skipped over the issue of shutdown(). From the close() documentation, "For portable behaviour with respect to graceful closure of a connected socket, call shutdown() before closing the socket".

    If deleting the socket does an implicit close, it seems that a call to shutdown() is still recommended before deleting it.

提交回复
热议问题