Multicast on same host

K

Karstens Rage

I have a simple multicast server using MulticastSocket and a joinGroup
and a simple client that uses DatagramSocket to send to that multicast
group (as a simple IP address). I also have a client in C running on
another host. If I run the C client the server only gets one datagram
packet and responds correctly. If I run the Java client on the same host
as the server, the server seems to get two packets from the same client.

I doubt the client is actually sending two packets. I think what may be
happening is that the network stack is passing two packets up (maybe one
from localhost and one from the network address of the machine).

I have fiddled with setNetworkInterface, setLoopbackMode (true and
false), and fiddling with the receive buffer for the actual call to
receive on the socket to no avail. I notice that if I set loopback to
true (disable), on the server, then the local Java client will not work
(just hangs in receive from the server and the server never gets anything)

Can anyone explain what is going on on the local host? Is there a
workaround so that server only gets one packet from the local client?

k

btw, using
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
 
E

EJP

Karstens said:
Can anyone explain what is going on on the local host? Is there a
workaround so that server only gets one packet from the local client?

There might be, but you are dealing with UDP, and one of the main
characteristics of UDP is that you may receive *any* datagram zero or
more times. So you may as well tackle that problem now while you have a
working testbed.
 
M

Mark Space

Karstens said:
Can anyone explain what is going on on the local host? Is there a
workaround so that server only gets one packet from the local client?

What OS & TCP/IP stack are you using? Are you sure multicast is
implemented?

I'm pretty sure multicast is one of those weird TCP/IP things that
somebody thought was a good idea, but most vendors decided not to
actually use. Even if it's implemented on your host, any switch or
router or gateway between you and your client might decide to toss
multicast packets away.

Better check around and find out. Can you sniff your network and see
what packets are being sent out and received?
 

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,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top