Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MulticastSocket problem

0 views
Skip to first unread message

Alessio

unread,
Sep 17, 2002, 5:57:05 AM9/17/02
to
import java.io.*;
import java.net.*;
import java.util.*;
import Multi;

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.


Knute Johnson

unread,
Sep 17, 2002, 12:43:23 PM9/17/02
to
Alessio wrote:

Alessio:

I tried it on my XP machine and it works fine. Might be that you have
something already running on port 6789.

knute...


0 new messages