/[xulu]/branches/1.8-gt2-2.6/src/appl/parallel/test/MulticastSocketTest.java
ViewVC logotype

Annotation of /branches/1.8-gt2-2.6/src/appl/parallel/test/MulticastSocketTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 47 - (hide annotations)
Mon Aug 31 14:23:19 2009 UTC (15 years, 3 months ago) by mojays
File size: 984 byte(s)
Branch 1.8-gt2-2.6 (from rev 45) for geotools 2.6 migration
1 mojays 2 package appl.parallel.test;
2    
3     import java.io.IOException;
4     import java.net.DatagramPacket;
5     import java.net.DatagramSocket;
6     import java.net.InetAddress;
7     import java.net.MulticastSocket;
8     import java.net.UnknownHostException;
9    
10     public class MulticastSocketTest {
11     public static void main( String[] args ) throws IOException
12     {
13    
14     String msg = "Hello";
15     InetAddress group = InetAddress.getByName("224.0.0.1");
16     MulticastSocket s = new MulticastSocket(50000);
17     s.joinGroup(group);
18     DatagramPacket hi = new DatagramPacket(msg.getBytes(), msg.length(),
19     group, 6789);
20     System.out.println("sending");
21     s.send(hi);
22     // get their responses!
23     System.out.println("waiting");
24     byte[] buf = new byte[1000];
25    
26     DatagramPacket recv = new DatagramPacket(buf, buf.length);
27     s.receive(recv);
28     System.out.println("finished");
29     // OK, I'm done talking - leave the group...
30     s.leaveGroup(group);
31    
32     }
33    
34     }
35    

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26