7 Jun
2010
7 Jun
'10
9:54 a.m.
bad designed api. close() does not need to be public -- it belongs into the destructor.
Usually socket destruction is the consequence of its closing. How would you emulate the following scheme, if it wouldn't be possible to close a socket? // pseudo-code struct connection : enable_shared_from_this<connection> { void read() { async_read(socket_, buffer_, bind(&read_handler, shared_from_this(), _1, _2); } void close() { socket_.close(); } private: tcp::socket socket_; };