users@grizzly.java.net

Re: multicast over Grizzly ?

From: Survivant 00 <survivant00_at_gmail.com>
Date: Tue, 11 Aug 2009 08:57:25 -0400

No body had an idea how to do that ?

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


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))





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 ?
>>
>
>