Merge pull request #13964 from ryanmcgrath/macos/qos

macoS: update QoSSession with SO_NET_SERVICE_TYPE.
This commit is contained in:
JMC47 2025-10-09 14:05:42 -04:00 committed by GitHub
commit 4f7a910e92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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