IP_ADD_MEMBERSHIP(2const)
π 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:
- See
IPPROTO_IP(2const). - See
setsockopt(2). - See
ip(7).
And the one it's claiming as its own:
EINVALβval->imr_multiaddris 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 a2constsituation, so the realsetsockopt(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