MCPcopy Create free account
hub / github.com/boostorg/asio / start_send

Method start_send

example/cpp11/icmp/ping.cpp:37–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36private:
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 {

Callers

nothing calls this directly

Calls 13

compute_checksumFunction · 0.85
codeMethod · 0.80
identifierMethod · 0.80
sequence_numberMethod · 0.80
nowFunction · 0.50
bindFunction · 0.50
typeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
send_toMethod · 0.45
dataMethod · 0.45
expires_atMethod · 0.45

Tested by

no test coverage detected