class prova{
public static void main(String[] args) throws IOException {
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);
// OK, I'm done talking - leave the group...
s.leaveGroup(group);
}
}
When I run this code found in the sun documentation I get this error:
Exception in thread "main" java.net.BindException: Cannot assign requested
address:
set socket option failed
at java.net.PlainDatagramSocketImpl.join(Native Method)
at java.net.MulticastSocket.joinGroup(MulticastSocket.java:229)
at prova.main(prova.java:13)
I get this error in localhost while the application is blocked if I try to
connect to Internet.
I am using Windows xp.
Alessio.
Alessio:
I tried it on my XP machine and it works fine. Might be that you have
something already running on port 6789.
knute...