I need to listen to 2 different multicast groups using the same port. Program A will listen from 230.0.0.1 and Program B from 23
Program A
230.0.0.1
Program B
23
If you change
in_addr.sin_addr.s_addr = htonl(INADDR_ANY);
to
inet_aton(, &in_addr.sin_addr.s_addr);
you could have more success.
(And if you change your program to work with getaddrinfo(), you make it future-proof.)