void do_write(boost::asio::ip::tcp::socket& socket, boost::asio::yield_context yield)
{
    using namespace boost::asio::ip;

    std::time_t now = std::time(0);
    std::string data = std::ctime(&now);
    boost::asio::async_write(socket, boost::asio::buffer(data), yield);
    socket.shutdown(tcp::socket::shutdown_send);
}
	inline void connection::handle_write(const boost::system::error_code& e)
	{
	    if (!e) {
		// Initiate graceful connection closure.
		boost::system::error_code ignored_ec;
		socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored_ec);
	    }

	    // No new asynchronous operations are started. This means that all shared_ptr
	    // references to the connection object will disappear and the object will be
	    // destroyed automatically after this handler returns. The connection class's
	    // destructor closes the socket.
	}
Beispiel #3
0
void handler::close() {
	boost::system::error_code ec;
	m_socket.shutdown(boost::asio::socket_base::shutdown_both, ec);
}