IP_MULTICAST_IF(2const)

๐Ÿ“ฆ
version 6.20 ยท 4 versions
, in arch rolling, nixpkgs unstable

๐Ÿ’– 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:


๐ŸŒˆ HISTORY ๐ŸŒˆ

  • Linux 1.2. yes she's an OG, been here since the dawn of time, main character energy fr fr ๐Ÿ‘‘

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘


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