Change UDP socket ReceiveMessage to perform peek first and then create a packet of the correct size.
Change-Id: Ia16538141d821744afcf616f615b43768d6af645
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1702868
Commit-Queue: Max Yakimakha <yakimakha@chromium.org>
Reviewed-by: mark a. foltz <mfoltz@chromium.org>
Reviewed-by: Ryan Keane <rwkeane@google.com>
diff --git a/platform/api/udp_socket.h b/platform/api/udp_socket.h
index 7ac9035..e060d41 100644
--- a/platform/api/udp_socket.h
+++ b/platform/api/udp_socket.h
@@ -10,6 +10,7 @@
#include <memory>
#include "platform/api/network_interface.h"
+#include "platform/api/udp_read_callback.h"
#include "platform/base/error.h"
#include "platform/base/ip_address.h"
#include "platform/base/macros.h"
@@ -79,13 +80,8 @@
// received. Note that a non-Error return value of 0 is a valid result,
// indicating an empty message has been received. Also note that
// Error::Code::kAgain might be returned if there is no message currently
- // ready for receive, which can be expected during normal operation. |src| and
- // |original_destination| are optional output arguments that provide the
- // source of the message and its intended destination, respectively.
- virtual ErrorOr<size_t> ReceiveMessage(void* data,
- size_t length,
- IPEndpoint* src,
- IPEndpoint* original_destination) = 0;
+ // ready for receive, which can be expected during normal operation.
+ virtual ErrorOr<UdpPacket> ReceiveMessage() = 0;
// Sends a message and returns the number of bytes sent, on success.
// Error::Code::kAgain might be returned to indicate the operation would