I made my UDP server and client with boost :: asio udp sockets. Everything looked good before I started sending more datagrams. They arrive correctly from the client to the server. But they are combined in my buffer into one message.
I use
udp::socket::async_receive with buffer std::array<char, 1 << 18 >
for async request. And receive data via callback
void on_receive(const error_code& code, size_t bytes_transferred)
If I send data too often (every 10 milliseconds), I get several datagrams at the same time in my buffer with the callback above. The question is how to select them? Note: my UDP datagrams are of variable length . I don’t want to use the add header with size, because it will make my code useless for third-party datagrams.
source
share