Skip to content

Instantly share code, notes, and snippets.

@vladimir-vg
Created May 10, 2015 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladimir-vg/ca3116a01d7013cc4e8c to your computer and use it in GitHub Desktop.
Save vladimir-vg/ca3116a01d7013cc4e8c to your computer and use it in GitHub Desktop.
#if defined(IP_TOS) && defined(SOL_IP) && defined(SO_PRIORITY)
static int setopt_prio_tos_trick
(int fd, int proto, int type, char* arg_ptr, int arg_sz, int propagate)
{
/* The relations between SO_PRIORITY, TOS and other options
is not what you (or at least I) would expect...:
If TOS is set after priority, priority is zeroed.
If any other option is set after tos, tos might be zeroed.
Therefore, save tos and priority. If something else is set,
restore both after setting, if tos is set, restore only
prio and if prio is set restore none... All to keep the
user feeling socket options are independent. /PaN */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment