Refactor UDPSocket creation
This patch removes the Version parameter in the Create method for UDPSocket,
and moves the endpoint parameter from the Bind() method to the
constructor. This makes the socket creation clearer, since you need to
have knowledge of the endpoint you want to connect to anyway if you know
what version it is going to be.
Change-Id: I1e867e71c20527f406e0c4c31bb28a70325ec15d
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1721055
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Reviewed-by: Max Yakimakha <yakimakha@chromium.org>
Reviewed-by: mark a. foltz <mfoltz@chromium.org>
diff --git a/platform/api/udp_socket.h b/platform/api/udp_socket.h
index e060d41..3639891 100644
--- a/platform/api/udp_socket.h
+++ b/platform/api/udp_socket.h
@@ -58,14 +58,14 @@
// Creates a new, scoped UdpSocket within the IPv4 or IPv6 family. This method
// must be defined in the platform-level implementation.
- static ErrorOr<UdpSocketUniquePtr> Create(Version version);
+ static ErrorOr<UdpSocketUniquePtr> Create(const IPEndpoint& endpoint);
// Returns true if |socket| belongs to the IPv4/IPv6 address family.
virtual bool IsIPv4() const = 0;
virtual bool IsIPv6() const = 0;
- // Sets the socket for address reuse, binds to the address/port.
- virtual Error Bind(const IPEndpoint& local_endpoint) = 0;
+ // Binds to the address specified in the constructor.
+ virtual Error Bind() = 0;
// Sets the device to use for outgoing multicast packets on the socket.
virtual Error SetMulticastOutboundInterface(