Receiving Unicast packets on Multicast socket

R

Rich DeMarinis

Is it possible to have a single MulticastSocket also receive Unicast
packets in Java? I'm able to bind one of each socket to the same port
but I'd like to be able to use just one socket. I'm running under
RedHat 9.0.

Thanks,
Rich
 
G

Gordon Beaton

Is it possible to have a single MulticastSocket also receive Unicast
packets in Java? I'm able to bind one of each socket to the same
port but I'd like to be able to use just one socket. I'm running
under RedHat 9.0.

Yes, since your application uses the same port number for unicast and
multicast datagrams.

MulticastSocket is a subclass of DatagramSocket, so it can receive
unicast datagrams. This is regardless of any multicast groups it has
joined, however it will only receive datagrams (of either kind) sent
to the bound port.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top