/[xulu]/trunk/src/appl/parallel/test/MulticastSocketTest.java
ViewVC logotype

Contents of /trunk/src/appl/parallel/test/MulticastSocketTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 78 - (show annotations)
Wed Feb 10 16:43:46 2010 UTC (14 years, 10 months ago) by alfonx
File size: 912 byte(s)
Merged branch 1.8-gt2-2.6 to trunk. Now the trunk is based on GeoTools 2.6.1 and schmitzm-2.0.x
1 package appl.parallel.test;
2
3 import java.io.IOException;
4 import java.net.DatagramPacket;
5 import java.net.InetAddress;
6 import java.net.MulticastSocket;
7
8 public class MulticastSocketTest {
9 public static void main( String[] args ) throws IOException
10 {
11
12 String msg = "Hello";
13 InetAddress group = InetAddress.getByName("224.0.0.1");
14 MulticastSocket s = new MulticastSocket(50000);
15 s.joinGroup(group);
16 DatagramPacket hi = new DatagramPacket(msg.getBytes(), msg.length(),
17 group, 6789);
18 System.out.println("sending");
19 s.send(hi);
20 // get their responses!
21 System.out.println("waiting");
22 byte[] buf = new byte[1000];
23
24 DatagramPacket recv = new DatagramPacket(buf, buf.length);
25 s.receive(recv);
26 System.out.println("finished");
27 // OK, I'm done talking - leave the group...
28 s.leaveGroup(group);
29
30 }
31
32 }
33

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26