| 118 | } |
| 119 | |
| 120 | void |
| 121 | on_read( |
| 122 | beast::error_code ec, |
| 123 | std::size_t bytes_transferred) |
| 124 | { |
| 125 | boost::ignore_unused(bytes_transferred); |
| 126 | |
| 127 | if(ec) |
| 128 | return fail(ec, "read"); |
| 129 | |
| 130 | // Write the message to standard out |
| 131 | std::cout << res_ << std::endl; |
| 132 | |
| 133 | // Gracefully close the socket |
| 134 | stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec); |
| 135 | |
| 136 | // not_connected happens sometimes so don't bother reporting it. |
| 137 | if(ec && ec != beast::errc::not_connected) |
| 138 | return fail(ec, "shutdown"); |
| 139 | |
| 140 | // If we get here then the connection is closed gracefully |
| 141 | } |
| 142 | }; |
| 143 | |
| 144 | //------------------------------------------------------------------------------ |