1 /* |
1 /* |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
28 * @modules jdk.net |
28 * @modules jdk.net |
29 * @run main QuickAckTest |
29 * @run main QuickAckTest |
30 */ |
30 */ |
31 import java.io.IOException; |
31 import java.io.IOException; |
32 import java.net.DatagramSocket; |
32 import java.net.DatagramSocket; |
|
33 import java.net.InetAddress; |
33 import java.net.MulticastSocket; |
34 import java.net.MulticastSocket; |
34 import java.net.ServerSocket; |
35 import java.net.ServerSocket; |
35 import java.net.Socket; |
36 import java.net.Socket; |
36 import jdk.net.ExtendedSocketOptions; |
37 import jdk.net.ExtendedSocketOptions; |
37 import jdk.net.Sockets; |
38 import jdk.net.Sockets; |
38 |
39 |
39 public class QuickAckTest { |
40 public class QuickAckTest { |
40 |
41 |
41 private static final String LOCAL_HOST = "127.0.0.1"; |
|
42 |
|
43 public static void main(String args[]) throws IOException { |
42 public static void main(String args[]) throws IOException { |
44 |
43 |
45 try (ServerSocket ss = new ServerSocket(0); |
44 try (ServerSocket ss = new ServerSocket(0); |
46 Socket s = new Socket(LOCAL_HOST, ss.getLocalPort()); |
45 Socket s = new Socket(InetAddress.getLoopbackAddress(), ss.getLocalPort()); |
47 DatagramSocket ds = new DatagramSocket(0); |
46 DatagramSocket ds = new DatagramSocket(0); |
48 MulticastSocket mc = new MulticastSocket(0)) { |
47 MulticastSocket mc = new MulticastSocket(0)) { |
49 |
48 |
50 if (ss.supportedOptions().contains(ExtendedSocketOptions.TCP_QUICKACK)) { |
49 if (ss.supportedOptions().contains(ExtendedSocketOptions.TCP_QUICKACK)) { |
51 Sockets.setOption(ss, ExtendedSocketOptions.TCP_QUICKACK, true); |
50 Sockets.setOption(ss, ExtendedSocketOptions.TCP_QUICKACK, true); |