Example usage for java.net StandardSocketOptions IP_TOS

List of usage examples for java.net StandardSocketOptions IP_TOS

Introduction

In this page you can find the example usage for java.net StandardSocketOptions IP_TOS.

Prototype

SocketOption IP_TOS

To view the source code for java.net StandardSocketOptions IP_TOS.

Click Source Link

Document

The Type of Service (ToS) octet in the Internet Protocol (IP) header.

Usage

From source file:Test.java

public static void main(String[] args) throws Exception {
    SelectorProvider provider = SelectorProvider.provider();
    NetworkChannel socketChannel = provider.openSocketChannel();
    SocketAddress address = new InetSocketAddress(3080);
    socketChannel = socketChannel.bind(address);

    Set<SocketOption<?>> socketOptions = socketChannel.supportedOptions();

    System.out.println(socketOptions.toString());
    socketChannel.setOption(StandardSocketOptions.IP_TOS, 3);
    Boolean keepAlive = socketChannel.getOption(StandardSocketOptions.SO_KEEPALIVE);
}