From 5a6730ab4ed2a21d85fbfb7cf3fae20088d18fe6 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Mon, 22 Sep 2025 17:30:18 -0400 Subject: [PATCH] macoS: update QoSSession with SO_NET_SERVICE_TYPE. macOS does not support `SO_PRIORITY` on sockets, but it does apparently support configuring sockets with a priority flag via a parameter called `SO_NET_SERVICE_TYPE`. It doesn't appear to be especially well documented, but it seems to exist as far back as 10.11 (El Capitan). This patch sets QoSSession to treat connections as "responsive multimedia audio/video", which some docs appear to describe as "low delay tolerant, low-medium, loss tolerant, elastic flow, variable packet interval, rate and size". --- Source/Core/Common/QoSSession.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Core/Common/QoSSession.cpp b/Source/Core/Common/QoSSession.cpp index f1435174276..e2e3914e531 100644 --- a/Source/Core/Common/QoSSession.cpp +++ b/Source/Core/Common/QoSSession.cpp @@ -54,6 +54,15 @@ QoSSession::~QoSSession() #else QoSSession::QoSSession(ENetPeer* peer, int tos_val) { +// Apple systems don't support SO_PRIORITY on BSD sockets, but they do support a flag for +// marking sockets as a specific type of traffic. `NET_SERVICE_TYPE_RV` should roughly +// correspond to "low delay tolerant, low-medium loss tolerant, elastic flow, variable +// packet interval, rate and size". +#if defined(__APPLE__) + constexpr int srv_type = NET_SERVICE_TYPE_RV; + setsockopt(peer->host->socket, SOL_SOCKET, SO_NET_SERVICE_TYPE, &srv_type, sizeof(srv_type)); +#endif + #if defined(__linux__) constexpr int priority = 7; setsockopt(peer->host->socket, SOL_SOCKET, SO_PRIORITY, &priority, sizeof(priority));