dev@grizzly.java.net

Re: multicast over Grizzly ?

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Tue, 11 Aug 2009 15:10:02 +0200

Hi Sebastien,

> No body had an idea how to do that ?
Sorry, it's quite tough with time now...
Don't we try to workaround this using asynchronous write queue? I
remember we were solving something with multicasting, don't we?

> I checked in the unittest and we have UDPIOClient. But it's using
> plain DatagramSocket.
Right.

>
> I have 3 cases.
>
> #1 - Send a UDP message using MulticastSocket and close the socket.
> #2 - Send a UDP message using DatagramSocket but wait for a response
> (wait until TTL)
> #3 - Listen for UDP message using MulticastSocket (while(true))
Probably I can try to implement that for Grizzly 2.0, cause for
Grizzly 1.9.x it could mean changing existing API, which I don't want
to do :)

WBR,
Alexey.
>
>
>
>
>
> 2009/8/7 Survivant 00 <survivant00_at_gmail.com>
> I didn't mean multicast like JDK7.. but a broadcast like this
>
> SERVER
> MulticastSocket ssdpUniSock = null;
> InetAddress group = null;
>
> try {
> group = InetAddress.getByName(host);
> ssdpUniSock = new MulticastSocket(port);
> ssdpUniSock.joinGroup(group);
>
> byte ssdvRecvBuf[] = new byte[1024];
> DatagramPacket dgmPacket2 = new
> DatagramPacket(ssdvRecvBuf, 1024);
>
> ssdpUniSock.receive(dgmPacket2);
>
> .....
>
> CLIENT
>
> MulticastSocket ssdpUniSock = new MulticastSocket(null);
> ssdpUniSock.setReuseAddress(true);
>
> String msg = "Grizzly is the best";
>
> logger.info("sending message \n" + msg);
>
> DatagramPacket dgmPacket = new
> DatagramPacket(msg.getBytes(), msg.length(),
> InetAddress.getByName(host), port);
>
> ssdpUniSock.send(dgmPacket);
>
> ssdpUniSock.close();
>
>
>
>
> 2009/8/7 Survivant 00 <survivant00_at_gmail.com>
>
> I'm trying to do multicast over Grizzly. (client and server .. send/
> receive)
>
> - first.. is it possible ?
> - there is a sample somewhere ?
>
> Grizzly 1.x or Grizzly 2 is ok for me.
>
> maybe if we don't have multicast. There is a sample for UDP that
> could give the same result ?
>
>