service: bsd: Add keepalive socket option
This commit is contained in:
parent
f05e87402a
commit
1c3983c12e
4 changed files with 10 additions and 0 deletions
|
@ -689,6 +689,9 @@ Errno BSD::SetSockOptImpl(s32 fd, u32 level, OptName optname, size_t optlen, con
|
||||||
case OptName::REUSEADDR:
|
case OptName::REUSEADDR:
|
||||||
ASSERT(value == 0 || value == 1);
|
ASSERT(value == 0 || value == 1);
|
||||||
return Translate(socket->SetReuseAddr(value != 0));
|
return Translate(socket->SetReuseAddr(value != 0));
|
||||||
|
case OptName::KEEPALIVE:
|
||||||
|
ASSERT(value == 0 || value == 1);
|
||||||
|
return Translate(socket->SetKeepAlive(value != 0));
|
||||||
case OptName::BROADCAST:
|
case OptName::BROADCAST:
|
||||||
ASSERT(value == 0 || value == 1);
|
ASSERT(value == 0 || value == 1);
|
||||||
return Translate(socket->SetBroadcast(value != 0));
|
return Translate(socket->SetBroadcast(value != 0));
|
||||||
|
|
|
@ -46,6 +46,7 @@ enum class Protocol : u32 {
|
||||||
|
|
||||||
enum class OptName : u32 {
|
enum class OptName : u32 {
|
||||||
REUSEADDR = 0x4,
|
REUSEADDR = 0x4,
|
||||||
|
KEEPALIVE = 0x8,
|
||||||
BROADCAST = 0x20,
|
BROADCAST = 0x20,
|
||||||
LINGER = 0x80,
|
LINGER = 0x80,
|
||||||
SNDBUF = 0x1001,
|
SNDBUF = 0x1001,
|
||||||
|
|
|
@ -600,6 +600,10 @@ Errno Socket::SetReuseAddr(bool enable) {
|
||||||
return SetSockOpt<u32>(fd, SO_REUSEADDR, enable ? 1 : 0);
|
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) {
|
Errno Socket::SetBroadcast(bool enable) {
|
||||||
return SetSockOpt<u32>(fd, SO_BROADCAST, enable ? 1 : 0);
|
return SetSockOpt<u32>(fd, SO_BROADCAST, enable ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
|
|
||||||
Errno SetReuseAddr(bool enable);
|
Errno SetReuseAddr(bool enable);
|
||||||
|
|
||||||
|
Errno SetKeepAlive(bool enable);
|
||||||
|
|
||||||
Errno SetBroadcast(bool enable);
|
Errno SetBroadcast(bool enable);
|
||||||
|
|
||||||
Errno SetSndBuf(u32 value);
|
Errno SetSndBuf(u32 value);
|
||||||
|
|
Loading…
Reference in a new issue