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

Function main

example/cpp11/tutorial/daytime5/server.cpp:26–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26int main()
27{
28 try
29 {
30 boost::asio::io_context io_context;
31
32 udp::socket socket(io_context, udp::endpoint(udp::v4(), 13));
33
34 for (;;)
35 {
36 std::array<char, 1> recv_buf;
37 udp::endpoint remote_endpoint;
38 socket.receive_from(boost::asio::buffer(recv_buf), remote_endpoint);
39
40 std::string message = make_daytime_string();
41
42 boost::system::error_code ignored_error;
43 socket.send_to(boost::asio::buffer(message),
44 remote_endpoint, 0, ignored_error);
45 }
46 }
47 catch (std::exception& e)
48 {
49 std::cerr << e.what() << std::endl;
50 }
51
52 return 0;
53}

Callers

nothing calls this directly

Calls 5

bufferFunction · 0.85
make_daytime_stringFunction · 0.70
endpointClass · 0.50
receive_fromMethod · 0.45
send_toMethod · 0.45

Tested by

no test coverage detected