IP_ADD_MEMBERSHIP(2const)

πŸ“¦
version 6.20 Β· 4 versions
, in arch rolling, nixpkgs unstable

πŸ’– IP_ADD_MEMBERSHIP πŸ’–

okay so bestie, this one lives in the 2const girlies β€” it's a little constant that rides along with setsockopt(2), and it's literally just "hey kernel, put me in the group chat." no cap. πŸŽ€


✨ NAME ✨

IP_ADD_MEMBERSHIP β€” join a multicast group 🫢


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <netinet/in.h>  /* Definition of IP* constants */
#include <sys/socket.h>

int setsockopt(int sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
               const struct ip_mreqn *val, sizeof(struct ip_mreqn));

πŸ‘‘ DESCRIPTION πŸ‘‘

Join a multicast group. That's it, that's the whole vibe. You're sliding into the multicast DMs. πŸ“¬βœ¨

IP_ADD_MEMBERSHIP is valid only for setsockopt(2). Like, that's its whole lane. Don't try to make it do anything else, it will not. πŸ’…


πŸ’€ ERRORS πŸ’€

Not me making you read the other pages too β€” but fr fr:

And the one it's claiming as its own:

  • EINVAL β€” val->imr_multiaddr is not a valid multicast address. 😭 bestie that address is giving absolutely nothing. Check it before you send it.

🌈 HISTORY 🌈

Linux 1.2 β€” old school, ancient, still iconic. πŸ’œ

For compatibility, the old ip_mreq structure is still supported. The kernel determines which structure is being passed based on the size passed in the last argument. so yeah, the size you hand over is literally the vibe check that tells the kernel which struct it's looking at. 🧚


🌸 SEE ALSO 🌸

IPPROTO_IP(2const), ip_mreqn(2type), setsockopt(2), ip(7)


small reminder, bestie: this whole page is a 2const situation, so the real setsockopt(2) energy lives over there. go read it, i'll wait. πŸ’–

sign-off time ✨ this whole thing is from Linux man-pages 6.20, dated 2025-11-25 β€” slay, era, periodt. πŸŽ€πŸ¦‹

πŸ“¦ 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