IP_TOS(2const)
π IP_TOS β type of service π
okay bestie, welcome to the IP_TOS(2const) page, she's short, she's iconic, she's the one who decides how fancy your packets get to act on the network πβ¨
This one lives in the Standard C library (libc, -lc), just so you know where to send the vibes π«Ά
β¨ SYNOPSIS β¨
#include <netinet/in.h> /* Definition of IP* constants */
#include <sys/socket.h>
int setsockopt(int sockfd, IPPROTO_IP, IP_TOS,
const int *tos, sizeof(int));
int getsockopt(int sockfd, IPPROTO_IP, IP_TOS,
int *tos, sizeof(int));
π DESCRIPTION π
So basically, IP_TOS lets you set or receive the Type-Of-Service (TOS) field that gets sent along with every single IP packet that originates from this socket π. What is it for? Prioritizing packets on the network, periodt.
There's a little roster of standard TOS flags defined for you, and honestly? They ate:
IPTOS_LOWDELAYβ to minimize delays for interactive traffic,IPTOS_THROUGHPUTβ to optimize throughput,IPTOS_RELIABILITYβ to optimize for reliability,IPTOS_MINCOSTβ should be used for "filler data" where slow transmission doesn't matter.
β οΈ okay listen up, this part is important: at most one of these TOS values can be specified. Other bits are invalid and shall be cleared. No mix-and-matching, bestie, that's not the move π
Linux sends IPTOS_LOWDELAY datagrams first by default, but fr fr, the exact behavior depends on the configured queueing discipline. So it's giving "defaults to main character, but the queue decides the plot" π
Alsooo, some high-priority levels may require superuser privileges (the CAP_NET_ADMIN capability). So don't be shocked if you need the fancy permissions β¨
π ERRORS π
See IPPROTO_IP(2const). See setsockopt(2). See ip(7). (yeah she's pointing you at her friends, that's the whole section, no notes π)
πΈ HISTORY πΈ
- Linux 1.0. β she's been here since basically forever, lowkey a legend π¦
π§ SEE ALSO π§
that's the whole page, bestie, you understood it perfectly, i'm so proud of you π₯Ήπ go set some TOS bits responsibly, mwah π β¨ from the Linux man-pages 6.20, dated 2025-11-25 ππ«Ά
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms