fd/ops: Add accept() with addr return
Change-Id: I0e7062086e66993f17b4f46bbc3285aabee348a9
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include-fd/stdplus/fd/ops.hpp b/include-fd/stdplus/fd/ops.hpp
index 7dc47ef..4296e2b 100644
--- a/include-fd/stdplus/fd/ops.hpp
+++ b/include-fd/stdplus/fd/ops.hpp
@@ -181,6 +181,18 @@
return DupableFd(std::move(std::get<0>(*ret)));
}
+inline std::optional<DupableFd> accept(Fd& fd, SockAddrBuf& addr)
+{
+ auto ret =
+ fd.accept(std::span(reinterpret_cast<std::byte*>(&addr), addr.maxLen));
+ if (!ret)
+ {
+ return std::nullopt;
+ }
+ addr.len = std::get<1>(*ret).size();
+ return DupableFd(std::move(std::get<0>(*ret)));
+}
+
template <typename Opt>
inline void setsockopt(Fd& fd, SockLevel level, SockOpt optname, Opt&& opt)
{