mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-16 05:21:22 +00:00
fix messages native flags
This commit is contained in:
@@ -1106,19 +1106,45 @@ std::pair<s32, Errno> Socket::RecvFrom(int flags, std::span<u8> message, Network
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> Socket::Send(std::span<const u8> message, int flags) {
|
||||
ASSERT(message.size() < static_cast<size_t>((std::numeric_limits<int>::max)()));
|
||||
ASSERT(flags == 0);
|
||||
ASSERT(message.size() < size_t((std::numeric_limits<int>::max)()));
|
||||
|
||||
int native_flags = 0;
|
||||
#ifdef MSG_OOB
|
||||
if (flags & int(MsgOpt::OOB)) native_flags |= MSG_OOB;
|
||||
#endif
|
||||
#ifdef MSG_PEEK
|
||||
if (flags & int(MsgOpt::PEEK)) native_flags |= MSG_PEEK;
|
||||
#endif
|
||||
#ifdef MSG_DONTROUTE
|
||||
if (flags & int(MsgOpt::DONTROUTE)) native_flags |= MSG_DONTROUTE;
|
||||
#endif
|
||||
#ifdef MSG_EOR
|
||||
if (flags & int(MsgOpt::EOR_)) native_flags |= MSG_EOR;
|
||||
#endif
|
||||
#ifdef MSG_TRUNC
|
||||
if (flags & int(MsgOpt::TRUNC)) native_flags |= MSG_TRUNC;
|
||||
#endif
|
||||
#ifdef MSG_CTRUNC
|
||||
if (flags & int(MsgOpt::CTRUNC)) native_flags |= MSG_CTRUNC;
|
||||
#endif
|
||||
#ifdef MSG_WAITALL
|
||||
if (flags & int(MsgOpt::WAITALL)) native_flags |= MSG_WAITALL;
|
||||
#endif
|
||||
#ifdef MSG_DONTWAIT
|
||||
if (flags & int(MsgOpt::DONTWAIT)) native_flags |= MSG_DONTWAIT;
|
||||
#endif
|
||||
#ifdef MSG_EOF
|
||||
if (flags & int(MsgOpt::EOF_)) native_flags |= MSG_EOF;
|
||||
#endif
|
||||
|
||||
#ifdef __unix__
|
||||
// NOSIGNAL is set for all sockets
|
||||
native_flags |= MSG_NOSIGNAL; // do not send us SIGPIPE
|
||||
#endif
|
||||
const auto result = send(fd, reinterpret_cast<const char*>(message.data()),
|
||||
static_cast<int>(message.size()), native_flags);
|
||||
const auto result = send(fd, reinterpret_cast<const char*>(message.data()), int(message.size()), native_flags);
|
||||
if (result != SOCKET_ERROR) {
|
||||
return {static_cast<s32>(result), Errno::SUCCESS};
|
||||
return {s32(result), Errno::SUCCESS};
|
||||
}
|
||||
|
||||
return {-1, GetAndLogLastError(CallType::Send)};
|
||||
}
|
||||
|
||||
|
||||
@@ -238,6 +238,19 @@ enum class SocketLevel : u32 {
|
||||
SOCKET = 0xffff, // i.e. SOL_SOCKET
|
||||
};
|
||||
|
||||
enum class MsgOpt : u32 {
|
||||
OOB = 0x00001,
|
||||
PEEK = 0x00002,
|
||||
DONTROUTE = 0x00004,
|
||||
EOR_ = 0x00008,
|
||||
TRUNC = 0x00010,
|
||||
CTRUNC = 0x00020,
|
||||
WAITALL = 0x00040,
|
||||
DONTWAIT = 0x00080,
|
||||
EOF_ = 0x00100,
|
||||
NOSIGNAL = 0x20000,
|
||||
};
|
||||
|
||||
enum class OptName : u32 {
|
||||
REUSEADDR = 0x0004,
|
||||
KEEPALIVE = 0x0008,
|
||||
|
||||
Reference in New Issue
Block a user