Hey,

The setsockopt() for SO_REUSEADDR is at the wrong level.
Try the SOL_SOCKET instead of IPPROTO_IP.

Tuan


On 28 Sep 1999 [EMAIL PROTECTED] wrote:

> I want to have several incarnations of the same program listening to the same
> multicast address/port.  But I'm currently getting a 
> 
> listener: can't bind local socket (errno 98)
> 
> error on the second incarnation.  Here is my code:
> 
>   sockfd = socket(AF_INET, SOCK_DGRAM, 0);
> 
>   bzero ((char *) &mreq, sizeof (mreq));
>   mreq.imr_multiaddr.s_addr = inet_addr(udp_ip_addr);
>   mreq.imr_interface.s_addr = inet_addr(if_for_mc);
>   /*  mreq.imr_interface.s_addr = htonl(INADDR_ANY); */
> 
>   optval = 1;
>   setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
>   setsockopt(sockfd, IPPROTO_IP, SO_REUSEADDR, (char *)&optval, sizeof(optval));
> 
>   bzero((char *) &serv_addr, sizeof(serv_addr));
>   serv_addr.sin_family      = AF_INET;
>   serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
>   serv_addr.sin_port        = htons(atoi(av[3]));
> 
>   bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
> 
> I thought that the SO_REUSEADDR sockopt would let me re-bind to the same
> address?  What am I doing wrong?
> 
> Dave
> -
> To unsubscribe from this list: send the line "unsubscribe linux-net" in
> the body of a message to [EMAIL PROTECTED]
> 


-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to