IP_MULTICAST_IF(2const)
๐ IP_MULTICAST_IF โ bestie's guide to picking the local device for a multicast socket ๐
okay so real talk, this one's a constant page โ like, it's IP_MULTICAST_IF from the <netinet/in.h> squad, aka a 2const page, not a chunky full syscall page. It lives in the Standard C library (libc, link it with -lc). Let's get into it ๐ฆ
โจ SYNOPSIS โจ
#include <netinet/in.h> /* Definition of IP* constants */
#include <sys/socket.h>
int setsockopt(int sockfd, IPPROTO_IP, IP_MULTICAST_IF,
const void val[size], size_t size);
int getsockopt(int sockfd, IPPROTO_IP, IP_MULTICAST_IF,
struct in_addr *val, sizeof(struct in_addr));
๐ DESCRIPTION ๐
So like, what does it even do? It sets the local device for a multicast socket. That's the whole vibe ๐
When you're calling setsockopt(2), the argument you pass is one of these three cuties:
- an
ip_mreqn(2type)structure, - an
ip_mreq(2type)structure โ but only since Linux 3.5, slay for that version bump โจ - or an
in_addr(2type)structure.
And here's the iconic part: the kernel figures out which structure you're handing it based on the size you pass in size. It's giving mind-reader energy but make it syscall. ๐ฎ
๐ ERRORS ๐
ngl there's no giant error list here bestie, it just points you at the real ones:
- See
IPPROTO_IP(2const). - See
setsockopt(2). - See
ip(7).
๐ HISTORY ๐
- Linux 1.2. yes she's an OG, been here since the dawn of time, main character energy fr fr ๐
๐ SEE ALSO ๐
IPPROTO_IP(2const)in_addr(2type)ip_mreqn(2type)setsockopt(2)ip(7)
lowkey this page is short but it ate, no cap. Now go set that multicast device bestie ๐ซถ
That's the whole thing!! This was pulled straight from Linux man-pages 6.20, dated 2025-11-25 โ so if the vibes ever change upstream, check the newer version, mwah ๐๐
๐ฆ 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