/[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 60 - (hide annotations)
Sun Oct 4 16:54:52 2009 UTC (15 years, 2 months ago) by alfonx
File size: 912 byte(s)
* organized imports
1 mojays 2 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