diff options
author | Eli Lipsitz <elipsitz@google.com> | 2023-03-08 22:45:27 +0000 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-08 22:45:27 +0000 |
commit | b2ce96addbb28ef7d4f6f63b77029a24bab6156a (patch) | |
tree | 7f1af9a3ea7fcf9fe74267cd29729f9154f2b8b7 /pw_stream/BUILD.bazel | |
parent | 28f28fb1e65a8746a1c6eece2025b841ee8ce648 (diff) | |
download | pigweed-b2ce96addbb28ef7d4f6f63b77029a24bab6156a.tar.gz |
pw_stream: Create ServerSocket class
This commit adds a new ServerSocket class that aims to improve on the
shortcomings of SocketStream (when used as a server). The class:
1) Supports multiple clients
2) Splits the Listen and Accept operations (the old Serve method was a
source of race conditions)
3) Allows for random port assignment
A user will now create a single ServerSocket, call `Listen` once, and
`Accept` as many times as needed, each call creates a new SocketStream
for communicating with that client.
Due to the improvements in ServerSocket, it and SocketStream can now be
tested reliably, so tests have been added.
Bug: b/271321951
Change-Id: Ic5cd42eb0e36169ed18891cc06d0704867cb0254
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/131611
Commit-Queue: Eli Lipsitz <elipsitz@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Diffstat (limited to 'pw_stream/BUILD.bazel')
-rw-r--r-- | pw_stream/BUILD.bazel | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pw_stream/BUILD.bazel b/pw_stream/BUILD.bazel index c4d910ade..edd2f4baa 100644 --- a/pw_stream/BUILD.bazel +++ b/pw_stream/BUILD.bazel @@ -143,3 +143,12 @@ pw_cc_test( "//pw_unit_test", ], ) + +pw_cc_test( + name = "socket_stream_test", + srcs = ["socket_stream_test.cc"], + deps = [ + ":socket_stream", + "//pw_unit_test", + ], +) |