net/SocketDescriptor: add sendmsg(), recvmsg() wrappers
This commit is contained in:
parent
a91920a8ff
commit
974ed0166c
|
@ -417,6 +417,12 @@ SocketDescriptor::Receive(std::span<std::byte> dest, int flags) const noexcept
|
||||||
return ::recv(Get(), (char *)dest.data(), dest.size(), flags);
|
return ::recv(Get(), (char *)dest.data(), dest.size(), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
SocketDescriptor::Receive(struct msghdr &msg, int flags) const noexcept
|
||||||
|
{
|
||||||
|
return ::recvmsg(Get(), &msg, flags);
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
SocketDescriptor::Send(std::span<const std::byte> src, int flags) const noexcept
|
SocketDescriptor::Send(std::span<const std::byte> src, int flags) const noexcept
|
||||||
{
|
{
|
||||||
|
@ -427,6 +433,16 @@ SocketDescriptor::Send(std::span<const std::byte> src, int flags) const noexcept
|
||||||
return ::send(Get(), (const char *)src.data(), src.size(), flags);
|
return ::send(Get(), (const char *)src.data(), src.size(), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
SocketDescriptor::Send(const struct msghdr &msg, int flags) const noexcept
|
||||||
|
{
|
||||||
|
#ifdef __linux__
|
||||||
|
flags |= MSG_NOSIGNAL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ::sendmsg(Get(), &msg, flags);
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
SocketDescriptor::ReadNoWait(std::span<std::byte> dest) const noexcept
|
SocketDescriptor::ReadNoWait(std::span<std::byte> dest) const noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -303,6 +303,12 @@ public:
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ssize_t Receive(std::span<std::byte> dest, int flags=0) const noexcept;
|
ssize_t Receive(std::span<std::byte> dest, int flags=0) const noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for recvmsg().
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
ssize_t Receive(struct msghdr &msg, int flags=0) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for send().
|
* Wrapper for send().
|
||||||
*
|
*
|
||||||
|
@ -311,6 +317,14 @@ public:
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ssize_t Send(std::span<const std::byte> src, int flags=0) const noexcept;
|
ssize_t Send(std::span<const std::byte> src, int flags=0) const noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for sendmsg().
|
||||||
|
*
|
||||||
|
* MSG_NOSIGNAL is implicitly added (if available).
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
ssize_t Send(const struct msghdr &msg, int flags=0) const noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ssize_t Read(std::span<std::byte> dest) const noexcept {
|
ssize_t Read(std::span<std::byte> dest) const noexcept {
|
||||||
return Receive(dest);
|
return Receive(dest);
|
||||||
|
|
Loading…
Reference in New Issue