multicast socket bind() address in use

multicast socket bind() address in use

Post by Steve Ross » Fri, 24 Sep 1999 04:00:00

I'm having a problem binding to a socket on a multicast addess. I'm
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,
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 -
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
to bind to 1024 it returns "address already in use." On the other linux
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() -
could be INADDR_ANY or the particular multicast address that I'm
in, or any other IP address, it still doesn't bind. If I change the port
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
regardless of whether something else is bound to it? (When I run netstat
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?



Research Engineer
Multimedia Communications Research Laboratory
Motorola Labs


1. Multicast using socket bound to IP looback address


    I have a question about the sequence of operations I am trying out.

-   A UDP server is started on the local machine listening on address
INADDR_ANY and port 9001.

-   A socket is created and bound on the 'loopback' address (
and on port 9002.

-   The server socket has an option set to listen to multicast address.

    The client (bound on loopback address) sends data on the machine's
IP address. This data is received at the server. The client then sends
data on the multicast address to which the server is listening to. The
server does not get the multicast packet.

    If the same program is run on SOLARIS the multicast packet is

    Here are my questions -

1)  Can I send a multicast packet on a socket bound on the IP loopback

2)  If yes, then does LINUX implement this functionality.

3)  If I get the packet on the server, how can I find out if it came on
the multicast address or on the unicast address.

    I know that I am setting the server socket options correctly,
because when I bind the client to the local IP address and send the
multicast packet the packet is received at the server.

Thanks for your answers and time.


(I dont speak for my company in this email)

Sent via
Before you buy.

2. Installing a 3com 10/100 card on redhat 6.0...

3. using bind() to bind socket to device

4. Colorado AB/FC-10 Tape Adapter board

5. bind to a multicast address

6. Voice modem as answering machine

7. calling connect() or bind() for recv. multicast sockets?

8. Printer driver for HP DeskJet 870Cse and SyQuest SparQ

9. binding to a multicast address with multiple listeners

10. multicast using tcp/ip sockets

11. > 1 process listening on (address, port) using multicast?

12. Problem using OSPF with GATED - multicast address unreachable

13. Problem with binding of socket addresses