boost::asio UDP 服务器,如何在不先执行 receive_from 的情况下发送?

boost::asio UDP server, how to send without having to do a receive_from first?

在所有udp服务器的例子中,都有如下代码。但就我而言,我只希望服务器发送,无论是否有客户端准备好接收。所以不想使用 receive_from 调用来获取端点。我可以在 boost 中执行此操作吗?

size_t length = sock.receive_from(
        boost::asio::buffer(data, max_length), sender_endpoint);
sock.send_to(boost::asio::buffer(data, length), sender_endpoint);

documentation of send_to 实际上包含一个示例,说明如何构造端点地址并发送给它,而不是先从端点接收。引用:

boost::asio::ip::udp::endpoint destination(
    boost::asio::ip::address::from_string("1.2.3.4"), 12345);
socket.send_to(boost::asio::buffer(data, size), destination);