diff options
| author | Dustin Mierau <dustin@mierau.me> | 2025-10-25 17:03:02 -0700 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2025-10-25 17:03:02 -0700 |
| commit | 9857e39c81ce73d4347fa026a031c8389e42c3f3 (patch) | |
| tree | 80fef947642aacb33d6e588cb7d8756bf4ad8eb8 /Hotline | |
| parent | 3b3b965842c47939ca54d0d1cbdf469346847f14 (diff) | |
Experiement with better socket options.
Diffstat (limited to 'Hotline')
| -rw-r--r-- | Hotline/Library/NetSocket.swift | 25 | ||||
| -rw-r--r-- | Hotline/MacApp.swift | 2 |
2 files changed, 16 insertions, 11 deletions
diff --git a/Hotline/Library/NetSocket.swift b/Hotline/Library/NetSocket.swift index a7d44ce..b1f1742 100644 --- a/Hotline/Library/NetSocket.swift +++ b/Hotline/Library/NetSocket.swift @@ -254,16 +254,21 @@ final class NetSocket: NSObject, StreamDelegate { if setsockopt(socketHandle, SOL_SOCKET, SO_KEEPALIVE, &value, size) != 0 { print("NetSocket: failed to set SO_KEEPALIVE"); } -// // Number of keepalives before close (including first keepalive packet) -// value = 5 -// if setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPCNT, &value, size) != 0 { -// print("NetSocket: failed to set TCP_KEEPCNT"); -// } -// // Idle time used when SO_KEEPALIVE is enabled. Sets how long connection must be idle before keepalive is sent. -// value = 60 -// if setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPALIVE, &value, size) != 0 { -// print("NetSocket: failed to set TCP_KEEPALIVE") -// } + // Number of keepalives before close (including first keepalive packet) + value = 5 + if setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPCNT, &value, size) != 0 { + print("NetSocket: failed to set TCP_KEEPCNT"); + } + // Idle time used when SO_KEEPALIVE is enabled. Sets how long connection must be idle before keepalive is sent. + value = 30 + if setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPALIVE, &value, size) != 0 { + print("NetSocket: failed to set TCP_KEEPALIVE") + } + // Idle time used when TCP_KEEPINTVL is enabled. Sets how long to wait between probes. + value = 10 + if setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPINTVL, &value, size) != 0 { + print("NetSocket: failed to set TCP_KEEPINTVL") + } } } } diff --git a/Hotline/MacApp.swift b/Hotline/MacApp.swift index 0682c1d..5d1b912 100644 --- a/Hotline/MacApp.swift +++ b/Hotline/MacApp.swift @@ -189,7 +189,7 @@ struct Application: App { Server(name: nil, description: nil, address: "") } .modelContainer(self.modelContainer) - .defaultSize(width: 750, height: 700) + .defaultSize(width: 690, height: 760) .defaultPosition(.center) .onChange(of: activeServerState) { AppState.shared.activeServerState = activeServerState |