From 1c3983c12e5df5a2a2f33dadf5e4a2f875fe2f47 Mon Sep 17 00:00:00 2001 From: tech-ticks Date: Thu, 7 Apr 2022 23:05:50 +0200 Subject: service: bsd: Add keepalive socket option --- src/core/hle/service/sockets/bsd.cpp | 3 +++ src/core/hle/service/sockets/sockets.h | 1 + src/core/network/network.cpp | 4 ++++ src/core/network/sockets.h | 2 ++ 4 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index fc93fb743..e5631c27e 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -689,6 +689,9 @@ Errno BSD::SetSockOptImpl(s32 fd, u32 level, OptName optname, size_t optlen, con case OptName::REUSEADDR: ASSERT(value == 0 || value == 1); return Translate(socket->SetReuseAddr(value != 0)); + case OptName::KEEPALIVE: + ASSERT(value == 0 || value == 1); + return Translate(socket->SetKeepAlive(value != 0)); case OptName::BROADCAST: ASSERT(value == 0 || value == 1); return Translate(socket->SetBroadcast(value != 0)); diff --git a/src/core/hle/service/sockets/sockets.h b/src/core/hle/service/sockets/sockets.h index 02dbbae40..d69c86431 100644 --- a/src/core/hle/service/sockets/sockets.h +++ b/src/core/hle/service/sockets/sockets.h @@ -46,6 +46,7 @@ enum class Protocol : u32 { enum class OptName : u32 { REUSEADDR = 0x4, + KEEPALIVE = 0x8, BROADCAST = 0x20, LINGER = 0x80, SNDBUF = 0x1001, diff --git a/src/core/network/network.cpp b/src/core/network/network.cpp index a3e0664b9..0784a165d 100644 --- a/src/core/network/network.cpp +++ b/src/core/network/network.cpp @@ -600,6 +600,10 @@ Errno Socket::SetReuseAddr(bool enable) { return SetSockOpt(fd, SO_REUSEADDR, enable ? 1 : 0); } +Errno Socket::SetKeepAlive(bool enable) { + return SetSockOpt(fd, SO_KEEPALIVE, enable ? 1 : 0); +} + Errno Socket::SetBroadcast(bool enable) { return SetSockOpt(fd, SO_BROADCAST, enable ? 1 : 0); } diff --git a/src/core/network/sockets.h b/src/core/network/sockets.h index 5e39e7c54..caaefce7c 100644 --- a/src/core/network/sockets.h +++ b/src/core/network/sockets.h @@ -67,6 +67,8 @@ public: Errno SetReuseAddr(bool enable); + Errno SetKeepAlive(bool enable); + Errno SetBroadcast(bool enable); Errno SetSndBuf(u32 value); -- cgit v1.2.3