net/SocketDescriptor: disable msghdr methods on Windows

This commit is contained in:
Max Kellermann 2024-01-18 15:33:57 +01:00
parent 0fbed6dec1
commit b68c3b7f55
2 changed files with 14 additions and 1 deletions

View File

@ -6,11 +6,12 @@
#include "StaticSocketAddress.hxx"
#include "IPv4Address.hxx"
#include "IPv6Address.hxx"
#include "MsgHdr.hxx"
#ifdef _WIN32
#include <ws2tcpip.h>
#else
#include "MsgHdr.hxx"
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@ -418,6 +419,8 @@ SocketDescriptor::Receive(std::span<std::byte> dest, int flags) const noexcept
return ::recv(Get(), (char *)dest.data(), dest.size(), flags);
}
#ifndef _WIN32
ssize_t
SocketDescriptor::Receive(struct msghdr &msg, int flags) const noexcept
{
@ -431,6 +434,8 @@ SocketDescriptor::Receive(std::span<const struct iovec> v, int flags) const noex
return Receive(msg, flags);
}
#endif // !_WIN32
ssize_t
SocketDescriptor::Send(std::span<const std::byte> src, int flags) const noexcept
{
@ -441,6 +446,8 @@ SocketDescriptor::Send(std::span<const std::byte> src, int flags) const noexcept
return ::send(Get(), (const char *)src.data(), src.size(), flags);
}
#ifndef _WIN32
ssize_t
SocketDescriptor::Send(const struct msghdr &msg, int flags) const noexcept
{
@ -457,6 +464,8 @@ SocketDescriptor::Send(std::span<const struct iovec> v, int flags) const noexcep
return Send(MakeMsgHdr(v), flags);
}
#endif // !_WIN32
ssize_t
SocketDescriptor::ReadNoWait(std::span<std::byte> dest) const noexcept
{

View File

@ -303,6 +303,7 @@ public:
[[nodiscard]]
ssize_t Receive(std::span<std::byte> dest, int flags=0) const noexcept;
#ifndef _WIN32
/**
* Wrapper for recvmsg().
*/
@ -314,6 +315,7 @@ public:
*/
[[nodiscard]]
ssize_t Receive(std::span<const struct iovec> v, int flags=0) const noexcept;
#endif // !_WIN32
/**
* Wrapper for send().
@ -323,6 +325,7 @@ public:
[[nodiscard]]
ssize_t Send(std::span<const std::byte> src, int flags=0) const noexcept;
#ifndef _WIN32
/**
* Wrapper for sendmsg().
*
@ -338,6 +341,7 @@ public:
*/
[[nodiscard]]
ssize_t Send(std::span<const struct iovec> v, int flags=0) const noexcept;
#endif // !_WIN32
[[nodiscard]]
ssize_t Read(std::span<std::byte> dest) const noexcept {