Hi.

I am developing a peer to peer system that works under the same subnet.
I use Java Multicast Socket for broadcasting UDP messages.
But i have a problem. In a laboratory with PCs, at first i use 2 of them to be peers to test and i run my program on them. In only 1/15 tries, the message i broadcasted from one peer is received from the other peer. For the rest 14 tries, the peer is receiving nothing.
I get the code from java.sun.com and i think the code shouldn't be incorrect, i am posting here:
Code:
String msg = "Hello";
InetAddress group = InetAddress.getByName("228.5.6.7");
MulticastSocket s = new MulticastSocket(6789);
s.joinGroup(group);
DatagramPacket hi = new DatagramPacket(msg.getBytes(), msg.length(),group, 6789);
s.send(hi);
// get their responses!
byte[] buf = new byte[1000];
DatagramPacket recv = new DatagramPacket(buf, buf.length);
s.receive(recv);
There is no router between the 2 hosts that run this program.
What am i doing wrong here?
The peers should send and receive broadcast messages. But why do they make it successful in 1/15 tries only. If that 1 successful try wouldn't happened, i would have thought that there's a problem with the LAN. But sometimes, very oftenly, the peer receives the broadcast. Why?
And i might not understood the Class D IP and multicast concept. That ip number : "228.5.6.7" is not a real ip address that represents a host. That is a special virtual ip for specifying "groups". Once a peer joined to that group (it does not connect to any server, does it?), it can receive all the broadcast messages that are sent to that group. But it can get only few of them? Why?
Thanks for any help..