Skip to main content

JxtaMulticastSocket: How to receive multiple messages?

No replies
fransk
Offline
Joined: 2011-01-06
Points: 0

Hello,

I hope this is a simple question..

I am trying out JXTA by running some of the examples from the book "Practical JXTA II". I am currently looking at the JXTA Multicast Socket examples. I see the following code being used to receive a message:

byte[] buffer = new byte[1000];

DatagramPacket datagramPacket = new DatagramPacket(buffer, buffer.length);

multicastSocket.receive(datagramPacket);

String message = new String(datagramPacket.getData(), 0, datagramPacket.getLength());

As far as I can tell, this only gets one message. What would be the way to get all new messages from the multicast socket (the peer group)?

Thanks!

Frans