I'm having a problem binding to a socket on a multicast addess. I'm
interested
only in reading the multicast address.
Here's what I'm doing:
1. I create a UDP socket
2. I use setsockopt options to set IP_MULTICAST_IF, IP_ADD_MEMBERSHIP,
and SO_REUSEADDR
3. I bind the socket to the multicast address and port number that I'm
interested in
I'm actually doing this twice, because I am interested in two ports -
they
happen to be 1024 and 1026 (immediately following the last reserved port
-
I don't know if this is significant)
I have two linux boxes, both running RH6.0. On one box, I can bind fine
to port 1026 and get the data from the multicast channel, but when it
tries
to bind to 1024 it returns "address already in use." On the other linux
box,
I get the same behavior, except reversed - port 1024 binds ok, but port
1026 says address already in use. I've found that it doesn't matter what
the address is in the sockaddr_in structure that is passed to bind() -
it
could be INADDR_ANY or the particular multicast address that I'm
interested
in, or any other IP address, it still doesn't bind. If I change the port
number
it will bind, but that doesn't do me any good, because the data that I'm
interested in is on ports 1024 and 1026.
Does anyone know how I can force a socket to bind to a particular
address,
regardless of whether something else is bound to it? (When I run netstat
from
the command line, it doesn't appear that anything is using the port
isn't binding)
SO_REUSEADDR doesn't seem to be enough. Does anyone else understand
this any better than I do?
TIA,
Steve
--
-------------------------------------------------------
Research Engineer
Multimedia Communications Research Laboratory
Motorola Labs
-------------------------------------------------------