blob: e568f537d27871d89349f39069e37472efa90e77 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/**
25 * @test
26 * @bug 4094894
27 * @summary On W95/W98 it's not possible to send a datagram >12k
28 * via the loopback address.
29 */
30
31import java.net.*;
32import java.io.*;
33
34public class Send12k {
35
36 static final int SEND_SIZE = 16 * 1024;
37
38 public static void main(String args[]) throws Exception {
39
40 DatagramSocket s1 = new DatagramSocket();
41 DatagramSocket s2 = new DatagramSocket();
42
43 byte b1[] = new byte[ SEND_SIZE ];
44 DatagramPacket p1 = new DatagramPacket(b1, 0, b1.length,
45 InetAddress.getLocalHost(),
46 s2.getLocalPort());
47 boolean sendOkay = true;
48 try {
49 s1.send(p1);
50 } catch (SocketException e) {
51 /*
52 * Prior to merlin a send of > 12k to loopback address
53 * would fail silently.
54 */
55 sendOkay = false;
56 }
57
58 if (sendOkay) {
59 byte b2[] = new byte[ SEND_SIZE * 2];
60 DatagramPacket p2 = new DatagramPacket( b2, SEND_SIZE * 2 );
61 s2.setSoTimeout(2000);
62
63 try {
64 s2.receive(p1);
65 } catch (InterruptedIOException ioe) {
66 throw new Exception("Datagram not received within timeout");
67 }
68
69 if (p1.getLength() != SEND_SIZE) {
70 throw new Exception("Received datagram incorrect size");
71 }
72 }
73
74 }
75
76}