Java AsynchronousServerSocketChannel get supported options

Description

Java AsynchronousServerSocketChannel get supported options

import java.net.InetSocketAddress;
import java.net.SocketOption;
import java.nio.channels.AsynchronousServerSocketChannel;
import java.util.Set;

public class Main {

   public static void main(String[] args) {
      try {//from  w  w w. jav a2 s . c  o  m
         final AsynchronousServerSocketChannel listener = AsynchronousServerSocketChannel.open();
         InetSocketAddress address = new InetSocketAddress("localhost", 5000);
         listener.bind(address);

         Set<SocketOption<?>> options = listener.supportedOptions();
         for (SocketOption<?> socketOption : options) {
            System.out.println(socketOption.toString() + ": " + listener.getOption(socketOption));
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}



PreviousNext

Related