diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2005-07-16 00:30:23 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-07-16 00:30:23 +0000 |
commit | f911ba985aa7fe0096c386c5be385ac5825ea527 (patch) | |
tree | a0b991cf5866ae1d616639b906ac001811d74508 /libjava/classpath/test/java.net/MulticastClient.java | |
parent | 6f4434b39b261de5317dc81ddfdd94d2e1d62b11 (diff) | |
download | gcc-f911ba985aa7fe0096c386c5be385ac5825ea527.zip gcc-f911ba985aa7fe0096c386c5be385ac5825ea527.tar.gz gcc-f911ba985aa7fe0096c386c5be385ac5825ea527.tar.bz2 |
Initial revision
From-SVN: r102074
Diffstat (limited to 'libjava/classpath/test/java.net/MulticastClient.java')
-rw-r--r-- | libjava/classpath/test/java.net/MulticastClient.java | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/libjava/classpath/test/java.net/MulticastClient.java b/libjava/classpath/test/java.net/MulticastClient.java new file mode 100644 index 0000000..8dc18fe --- /dev/null +++ b/libjava/classpath/test/java.net/MulticastClient.java @@ -0,0 +1,65 @@ +/* Test Multicast Sockets */ + +import java.net.*; +import java.io.*; + +public class MulticastClient +{ + +public static void +main(String[] argv) throws IOException +{ + System.out.println("Starting multicast tests"); + System.out.println("NOTE: You need to do an 'ifconfig <interface> " + + "multicast' or this will fail on linux"); + + byte[] buf = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o','r','l','d' }; + + /* Simple Send */ + System.out.println("Test 1: Multicast send/receive test"); + try + { + InetAddress addr = InetAddress.getByName("234.0.0.1"); + + MulticastSocket s = new MulticastSocket(); + DatagramPacket p = new DatagramPacket(buf, buf.length, addr, 3333); + + s.joinGroup(addr); + s.send(p); + s.close(); + } + catch(IOException e) + { + System.out.println("FAILED: simple multicast send: " + e); + } + + /* Options */ + System.out.println("Test 2: Multicast socket options"); + try + { + InetAddress addr; + MulticastSocket s = new MulticastSocket(); + + System.out.println("TTL = " + s.getTTL()); + System.out.println("Setting TTT to 121"); + s.setTTL((byte)12); + System.out.println("TTL = " + s.getTTL()); + + InetAddress oaddr = s.getInterface(); + System.out.println("Multicast Interface = " + oaddr); + System.out.println("Setting interface to localhost"); + addr = InetAddress.getByName("198.211.138.177"); + s.setInterface(addr); + System.out.println("Multicast Interface = " + s.getInterface()); + System.out.println("Setting interface to " + oaddr); + s.setInterface(oaddr); + System.out.println("Multicast Interface = " + s.getInterface()); + } + catch(IOException e) + { + System.out.println("FAILED: multicast options: " + e); + } +} + +} + |