Reland "Take out listen support from AsyncPacketSocket"
This is a reland of b141c162ee2ef88a7498ba8cb8bc852287f93ad2
Original change's description:
> Take out listen support from AsyncPacketSocket
>
> Moved to new interface class AsyncListenSocket.
>
> Bug: webrtc:13065
> Change-Id: Ib96ce154ba19979360ecd8144981d947ff5b8b18
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232607
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35234}
Bug: webrtc:13065
Change-Id: I88bebdd80ebe6bcf6ac635023924d79fbfb76813
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235960
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35260}
diff --git a/rtc_base/async_packet_socket.h b/rtc_base/async_packet_socket.h
index 8362604..ce36dd6 100644
--- a/rtc_base/async_packet_socket.h
+++ b/rtc_base/async_packet_socket.h
@@ -128,17 +128,31 @@
// CONNECTED to CLOSED.
sigslot::signal2<AsyncPacketSocket*, int> SignalClose;
- // Used only for listening TCP sockets.
- sigslot::signal2<AsyncPacketSocket*, AsyncPacketSocket*> SignalNewConnection;
-
private:
RTC_DISALLOW_COPY_AND_ASSIGN(AsyncPacketSocket);
};
-// TODO(bugs.webrtc.org/13065): Intended to be broken out into a separate class,
-// after downstream has adapted the new name. The main feature to move from
-// AsyncPacketSocket to AsyncListenSocket is the SignalNewConnection.
-using AsyncListenSocket = AsyncPacketSocket;
+// Listen socket, producing an AsyncPacketSocket when a peer connects.
+class RTC_EXPORT AsyncListenSocket : public sigslot::has_slots<> {
+ public:
+ enum class State {
+ kClosed,
+ kBound,
+ };
+
+ // Returns current state of the socket.
+ virtual State GetState() const = 0;
+
+ // Returns current local address. Address may be set to null if the
+ // socket is not bound yet (GetState() returns kBinding).
+ virtual SocketAddress GetLocalAddress() const = 0;
+
+ // Get/set options.
+ virtual int GetOption(Socket::Option opt, int* value) = 0;
+ virtual int SetOption(Socket::Option opt, int value) = 0;
+
+ sigslot::signal2<AsyncListenSocket*, AsyncPacketSocket*> SignalNewConnection;
+};
void CopySocketInformationToPacketInfo(size_t packet_size_bytes,
const AsyncPacketSocket& socket_from,