|
Boost Users : |
Subject: Re: [Boost-users] [asio] Reading datagram packets
From: Igor R (boost.lists_at_[hidden])
Date: 2009-01-22 18:45:36
>
> char m_buf[10];
> udp::endpoint m_endpoint;
> <-->
> udpSocket.async_receive_from(buffer(buf), m_endpoint, bind(ReadHandler,
> ...));
> service.run();
>
> If more than 10 characters were in the datagram packet, how can they be
> accessed?
> Calling other read methods (after processing in the ReadHandler) just
> appears to block (I guess it is looking for another packet).
>
In the ReadHandler you can synchronously read the remained data , like this
(untested!):
size_t avail = udpSocket.available();
std::vector<char> data(avail);
udpSocket.read(buffer(data));
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net