Re: [asio-users] asio::async_read with a udp::socket?
Brought to you by:
chris_kohlhoff
|
From: Christopher K. <ch...@ko...> - 2007-03-15 23:28:11
|
On Thu, 15 Mar 2007 12:26:36 +0100, "=C1kos Mar=F3y" <da...@ty...> said: > The line in question that give the error message: >=20 > asio::async_read(socket_, asio::buffer(inbound_header_), > boost::bind(f, > this, asio::placeholders::error, boost::ref(t), > boost::make_tuple(handler))); >=20 >=20 >=20 > what would be the proper way to call asio::async_read with a UDP socket? You don't :) The asio::async_read function is for stream-oriented sockets, whereas UDP is datagram-oriented. Use udp::socket::async_receive_from() (or maybe udp::socket::async_receive() depending on whether you have connected the socket or not). Note also that if you're using UDP then the message length is already part of the protocol. There is no need to include a message header that specifies the length of the message body. This is in the serialization example because a stream-oriented TCP socket doesn't have a concept of messages. Cheers, Chris |