yuzu-emu
/
yuzu
Archived
1
0
Fork 0

service: bsd: Add keepalive socket option

This commit is contained in:
tech-ticks 2022-04-07 23:05:50 +02:00
parent f05e87402a
commit 1c3983c12e
4 changed files with 10 additions and 0 deletions

View File

@ -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));

View File

@ -46,6 +46,7 @@ enum class Protocol : u32 {
enum class OptName : u32 {
REUSEADDR = 0x4,
KEEPALIVE = 0x8,
BROADCAST = 0x20,
LINGER = 0x80,
SNDBUF = 0x1001,

View File

@ -600,6 +600,10 @@ Errno Socket::SetReuseAddr(bool enable) {
return SetSockOpt<u32>(fd, SO_REUSEADDR, enable ? 1 : 0);
}
Errno Socket::SetKeepAlive(bool enable) {
return SetSockOpt<u32>(fd, SO_KEEPALIVE, enable ? 1 : 0);
}
Errno Socket::SetBroadcast(bool enable) {
return SetSockOpt<u32>(fd, SO_BROADCAST, enable ? 1 : 0);
}

View File

@ -67,6 +67,8 @@ public:
Errno SetReuseAddr(bool enable);
Errno SetKeepAlive(bool enable);
Errno SetBroadcast(bool enable);
Errno SetSndBuf(u32 value);