#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>

#define MSGSIZE 4096

main(int argc, char *argv[])
{
  struct sockaddr_in addr;
  int fd, addrlen;
  struct ip_mreq mreq;
  char message[MSGSIZE];

  fd=socket(AF_INET,SOCK_DGRAM,0);

  memset(&addr,0,sizeof(addr));
  addr.sin_family=AF_INET;
  addr.sin_addr.s_addr=htonl(INADDR_ANY);
  addr.sin_port=htons(12345);
  bind(fd,(struct sockaddr *) &addr, sizeof(addr));
  mreq.imr_multiaddr.s_addr=inet_addr("225.10.10.1");
  mreq.imr_interface.s_addr=htonl(INADDR_ANY);
  setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, 
      (char *) &mreq, sizeof(mreq));

  for(;;) {      
    recvfrom(fd, message, MSGSIZE,0, 
       (struct sockaddr *) & addr, &addrlen);
    puts(message);
  }
}
