1 /*
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
27 */
28
29 import com.sun.nio.sctp.*;
30 import java.io.IOException;
31 import java.net.InetAddress;
32 import java.net.InetSocketAddress;
33 import java.net.SocketAddress;
34 import java.nio.ByteBuffer;
35 import static java.lang.System.out;
36 import static java.nio.ByteBuffer.*;
37
38 public class SendFailed {
39
40 static final SocketAddress remoteAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 3000);
41
42 static final int[] bufferSizes =
43 { 20, 49, 50, 51, 100, 101, 1024, 1025, 4095, 4096, 4097, 8191, 8192, 8193};
44
45 void test(String[] args) throws IOException {
46 SocketAddress address = null;
47 String os = System.getProperty("os.name").toLowerCase();
48
49 if (!Util.isSCTPSupported()) {
50 out.println("SCTP protocol is not supported");
51 out.println("Test cannot be run");
52 return;
53 } else if (os.startsWith("sunos")) {
54 out.println("Test not supported on Solaris");
55 out.println("Test cannot be run");
56 return;
57 }
58
59 System.out.println("remote address: " + remoteAddress);
60 System.out.println("Note, remote address should not be up");
61
62 /* combinations with various buffer sizes, and offsets */
63 for (int send=0; send < bufferSizes.length; send++) {
64 for (int recv=0; recv < bufferSizes.length; recv++) {
65 for (boolean direct : new boolean[] {true, false})
66 runWithManyOffsets(bufferSizes[send], bufferSizes[recv], direct);
67 }
68 }
69 }
70
71 void runWithManyOffsets(int sendBufferSize, int recvBufferSize, boolean direct)
72 throws IOException
73 {
74 doTest(sendBufferSize, recvBufferSize, direct, 0);
|
1 /*
2 * Copyright (c) 2015, 2020, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
27 */
28
29 import com.sun.nio.sctp.*;
30 import java.io.IOException;
31 import java.net.InetAddress;
32 import java.net.InetSocketAddress;
33 import java.net.SocketAddress;
34 import java.nio.ByteBuffer;
35 import static java.lang.System.out;
36 import static java.nio.ByteBuffer.*;
37
38 public class SendFailed {
39
40 static final SocketAddress remoteAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 3000);
41
42 static final int[] bufferSizes =
43 { 20, 49, 50, 51, 100, 101, 1024, 1025, 4095, 4096, 4097, 8191, 8192, 8193};
44
45 void test(String[] args) throws IOException {
46 SocketAddress address = null;
47
48 if (!Util.isSCTPSupported()) {
49 out.println("SCTP protocol is not supported");
50 out.println("Test cannot be run");
51 return;
52 }
53
54 System.out.println("remote address: " + remoteAddress);
55 System.out.println("Note, remote address should not be up");
56
57 /* combinations with various buffer sizes, and offsets */
58 for (int send=0; send < bufferSizes.length; send++) {
59 for (int recv=0; recv < bufferSizes.length; recv++) {
60 for (boolean direct : new boolean[] {true, false})
61 runWithManyOffsets(bufferSizes[send], bufferSizes[recv], direct);
62 }
63 }
64 }
65
66 void runWithManyOffsets(int sendBufferSize, int recvBufferSize, boolean direct)
67 throws IOException
68 {
69 doTest(sendBufferSize, recvBufferSize, direct, 0);
|