// Wait for AcceptThread to set up its socket.
Thread.sleep(1000);
MulticastSocket mcSocket = new MulticastSocket(DISCOVERYPORT);
mcSocket.setTimeToLive(1);
Discovery d = Discovery.getProtocol1();
ServiceID sid = new ServiceID(5555, 4444);
MulticastAnnouncement ma = new MulticastAnnouncement(
2222,
InetAddress.getLocalHost().getHostName(),
DISCOVERYPORT,
groups,
sid);
final List packets = new ArrayList();
EncodeIterator ei = d.encodeMulticastAnnouncement(ma, 1024, null);
while (ei.hasNext()) {
packets.addAll(Arrays.asList(ei.next()));
}
DatagramPacket[] pArray = (DatagramPacket[]) packets.toArray(
new DatagramPacket[packets.size()]);