| 35 | |
| 36 | private: |
| 37 | void start_send() |
| 38 | { |
| 39 | std::string body("\"Hello!\" from Asio ping."); |
| 40 | |
| 41 | // Create an ICMP header for an echo request. |
| 42 | icmp_header echo_request; |
| 43 | echo_request.type(icmp_header::echo_request); |
| 44 | echo_request.code(0); |
| 45 | echo_request.identifier(get_identifier()); |
| 46 | echo_request.sequence_number(++sequence_number_); |
| 47 | compute_checksum(echo_request, body.begin(), body.end()); |
| 48 | |
| 49 | // Encode the request packet. |
| 50 | boost::asio::streambuf request_buffer; |
| 51 | std::ostream os(&request_buffer); |
| 52 | os << echo_request << body; |
| 53 | |
| 54 | // Send the request. |
| 55 | time_sent_ = steady_timer::clock_type::now(); |
| 56 | socket_.send_to(request_buffer.data(), destination_); |
| 57 | |
| 58 | // Wait up to five seconds for a reply. |
| 59 | num_replies_ = 0; |
| 60 | timer_.expires_at(time_sent_ + chrono::seconds(5)); |
| 61 | timer_.async_wait(std::bind(&pinger::handle_timeout, this)); |
| 62 | } |
| 63 | |
| 64 | void handle_timeout() |
| 65 | { |
nothing calls this directly
no test coverage detected