< prev index next >

test/jdk/jdk/net/Sockets/ExtOptionTest.java

Print this page
rev 59105 : imported patch corelibs


  31 import java.io.IOException;
  32 import java.net.ServerSocket;
  33 
  34 import static jdk.net.ExtendedSocketOptions.TCP_QUICKACK;
  35 import static jdk.net.ExtendedSocketOptions.SO_FLOW_SLA;
  36 
  37 public class ExtOptionTest {
  38 
  39     private static final String OS = "Linux";
  40 
  41     public static void main(String args[]) throws IOException {
  42         var operSys = System.getProperty("os.name");
  43         try (ServerSocket ss = new ServerSocket(0)) {
  44             // currently TCP_QUICKACK is available only on Linux.
  45             if (operSys.equals(OS)) {
  46                 ss.setOption(TCP_QUICKACK, true);
  47                 if (!ss.getOption(TCP_QUICKACK)) {
  48                     throw new RuntimeException("Test failed, TCP_QUICKACK should"
  49                             + " have been set");
  50                 }
  51             } else if (operSys.equals("SunOS")) {
  52                 if (ss.supportedOptions().contains(SO_FLOW_SLA)) {
  53                     throw new RuntimeException("Test failed, SO_FLOW_SLA is not "
  54                             + "applicable for ServerSocket");
  55                 }
  56             } else {
  57                 if (ss.supportedOptions().contains(TCP_QUICKACK)) {
  58                     ss.setOption(TCP_QUICKACK, true);
  59                     if (!ss.getOption(TCP_QUICKACK)) {
  60                         throw new RuntimeException("Test failed, TCP_QUICKACK should"
  61                                 + " have been set");
  62                     }
  63                 }
  64             }
  65         }
  66     }
  67 }


  31 import java.io.IOException;
  32 import java.net.ServerSocket;
  33 
  34 import static jdk.net.ExtendedSocketOptions.TCP_QUICKACK;
  35 import static jdk.net.ExtendedSocketOptions.SO_FLOW_SLA;
  36 
  37 public class ExtOptionTest {
  38 
  39     private static final String OS = "Linux";
  40 
  41     public static void main(String args[]) throws IOException {
  42         var operSys = System.getProperty("os.name");
  43         try (ServerSocket ss = new ServerSocket(0)) {
  44             // currently TCP_QUICKACK is available only on Linux.
  45             if (operSys.equals(OS)) {
  46                 ss.setOption(TCP_QUICKACK, true);
  47                 if (!ss.getOption(TCP_QUICKACK)) {
  48                     throw new RuntimeException("Test failed, TCP_QUICKACK should"
  49                             + " have been set");
  50                 }





  51             } else {
  52                 if (ss.supportedOptions().contains(TCP_QUICKACK)) {
  53                     ss.setOption(TCP_QUICKACK, true);
  54                     if (!ss.getOption(TCP_QUICKACK)) {
  55                         throw new RuntimeException("Test failed, TCP_QUICKACK should"
  56                                 + " have been set");
  57                     }
  58                 }
  59             }
  60         }
  61     }
  62 }
< prev index next >