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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Wed Feb 25 11:54:01 2009 UTC (15 years, 9 months ago) by mojays
Original Path: trunk/src/appl/parallel/test/MulticastSocketTest.java
File size: 984 byte(s)
First Commit, corresponds to Revision 1008 of Wikisquare-SVN 
1 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