i.e. will the blocking version return -1 on error.
Or more to the point, how do you know the call failed? does
boost::asio::ip::udp::socket::receive_from() return -1 on error
The normal BSD socket API receive_from call will return -1 on errors and you can look at errno for the specific error code. Does the boost version do the same?
Ok, I tried passing the overload like this:
while(true){
boost::system::error_code ec;
size_t length = socket_.receive_from(
boost::asio::buffer(buffer, buffer_size),
sender_endpoint, ec);
/// ... other code
}
But I get this error on compilation:
error: no matching function for call to ‘boost::asio::basic_datagram_socket<boost::asio::ipdp, boost::asio::datagram_socket_service<boost::asio::ip::udp> >::receive_from(boost::asio::mutable_buffer, boost::asio::ip::basic_endpoint<boost::asio::ip::udp>&, boost::system::error_code&)’
make: *** [server.o] Error 1
Is the documentation wrong or am I doing something wrong? EDIT: no I'm wrong... sorry I'm having a moment... it's called overwork! I'm half asleep right now. I'm missing the flags argument.