Receiving Unicast packets on Multicast socket

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.

Advertisements

On 22 Oct 2004 14:06:38 -0700, Rich DeMarinis wrote:
> 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.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!