sun.net.ExtendedOptionsImpl Java Examples

The following examples show how to use sun.net.ExtendedOptionsImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SocketChannelImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #2
Source File: SocketChannelImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #3
Source File: SocketChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #4
Source File: SocketChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #5
Source File: SocketChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #6
Source File: SocketChannelImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #7
Source File: SocketChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #8
Source File: SocketChannelImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #9
Source File: SocketChannelImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #10
Source File: SocketChannelImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.TCP_NODELAY);
    // additional options required by socket adaptor
    set.add(StandardSocketOptions.IP_TOS);
    set.add(ExtendedSocketOption.SO_OOBINLINE);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #11
Source File: DatagramChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_BROADCAST);
    set.add(StandardSocketOptions.IP_TOS);
    set.add(StandardSocketOptions.IP_MULTICAST_IF);
    set.add(StandardSocketOptions.IP_MULTICAST_TTL);
    set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #12
Source File: DatagramChannelImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_BROADCAST);
    set.add(StandardSocketOptions.IP_TOS);
    set.add(StandardSocketOptions.IP_MULTICAST_IF);
    set.add(StandardSocketOptions.IP_MULTICAST_TTL);
    set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #13
Source File: Net.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
                              SocketOption<?> name)
    throws IOException
{
    Class<?> type = name.type();

    if (type == SocketFlow.class) {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA"));
        }
        SocketFlow flow = SocketFlow.create();
        ExtendedOptionsImpl.getFlowOption(fd, flow);
        return flow;
    }

    // only simple values supported by this method
    if (type != Integer.class && type != Boolean.class)
        throw new AssertionError("Should not reach here");

    // map option name to platform level/name
    OptionKey key = SocketOptionRegistry.findOption(name, family);
    if (key == null)
        throw new AssertionError("Option not found");

    boolean mayNeedConversion = (family == UNSPEC);
    int value = getIntOption0(fd, mayNeedConversion, key.level(), key.name());

    if (type == Integer.class) {
        return Integer.valueOf(value);
    } else {
        return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
    }
}
 
Example #14
Source File: AsynchronousSocketChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.TCP_NODELAY);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #15
Source File: DatagramChannelImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_BROADCAST);
    set.add(StandardSocketOptions.IP_TOS);
    set.add(StandardSocketOptions.IP_MULTICAST_IF);
    set.add(StandardSocketOptions.IP_MULTICAST_TTL);
    set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #16
Source File: Net.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
                              SocketOption<?> name)
    throws IOException
{
    Class<?> type = name.type();

    if (type == SocketFlow.class) {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA"));
        }
        SocketFlow flow = SocketFlow.create();
        ExtendedOptionsImpl.getFlowOption(fd, flow);
        return flow;
    }

    // only simple values supported by this method
    if (type != Integer.class && type != Boolean.class)
        throw new AssertionError("Should not reach here");

    // map option name to platform level/name
    OptionKey key = SocketOptionRegistry.findOption(name, family);
    if (key == null)
        throw new AssertionError("Option not found");

    boolean mayNeedConversion = (family == UNSPEC);
    int value = getIntOption0(fd, mayNeedConversion, key.level(), key.name());

    if (type == Integer.class) {
        return Integer.valueOf(value);
    } else {
        return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
    }
}
 
Example #17
Source File: AsynchronousSocketChannelImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.TCP_NODELAY);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #18
Source File: DatagramChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_BROADCAST);
    set.add(StandardSocketOptions.IP_TOS);
    set.add(StandardSocketOptions.IP_MULTICAST_IF);
    set.add(StandardSocketOptions.IP_MULTICAST_TTL);
    set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #19
Source File: Net.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
                              SocketOption<?> name)
    throws IOException
{
    Class<?> type = name.type();

    if (type == SocketFlow.class) {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA"));
        }
        SocketFlow flow = SocketFlow.create();
        ExtendedOptionsImpl.getFlowOption(fd, flow);
        return flow;
    }

    // only simple values supported by this method
    if (type != Integer.class && type != Boolean.class)
        throw new AssertionError("Should not reach here");

    // map option name to platform level/name
    OptionKey key = SocketOptionRegistry.findOption(name, family);
    if (key == null)
        throw new AssertionError("Option not found");

    boolean mayNeedConversion = (family == UNSPEC);
    int value = getIntOption0(fd, mayNeedConversion, key.level(), key.name());

    if (type == Integer.class) {
        return Integer.valueOf(value);
    } else {
        return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
    }
}
 
Example #20
Source File: AsynchronousSocketChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.TCP_NODELAY);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #21
Source File: DatagramChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_BROADCAST);
    set.add(StandardSocketOptions.IP_TOS);
    set.add(StandardSocketOptions.IP_MULTICAST_IF);
    set.add(StandardSocketOptions.IP_MULTICAST_TTL);
    set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #22
Source File: Net.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
                              SocketOption<?> name)
    throws IOException
{
    Class<?> type = name.type();

    if (type == SocketFlow.class) {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA"));
        }
        SocketFlow flow = SocketFlow.create();
        ExtendedOptionsImpl.getFlowOption(fd, flow);
        return flow;
    }

    // only simple values supported by this method
    if (type != Integer.class && type != Boolean.class)
        throw new AssertionError("Should not reach here");

    // map option name to platform level/name
    OptionKey key = SocketOptionRegistry.findOption(name, family);
    if (key == null)
        throw new AssertionError("Option not found");

    boolean mayNeedConversion = (family == UNSPEC);
    int value = getIntOption0(fd, mayNeedConversion, key.level(), key.name());

    if (type == Integer.class) {
        return Integer.valueOf(value);
    } else {
        return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
    }
}
 
Example #23
Source File: AsynchronousSocketChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.TCP_NODELAY);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #24
Source File: DatagramChannelImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_BROADCAST);
    set.add(StandardSocketOptions.IP_TOS);
    set.add(StandardSocketOptions.IP_MULTICAST_IF);
    set.add(StandardSocketOptions.IP_MULTICAST_TTL);
    set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #25
Source File: Net.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
                              SocketOption<?> name)
    throws IOException
{
    Class<?> type = name.type();

    if (type == SocketFlow.class) {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA"));
        }
        SocketFlow flow = SocketFlow.create();
        ExtendedOptionsImpl.getFlowOption(fd, flow);
        return flow;
    }

    // only simple values supported by this method
    if (type != Integer.class && type != Boolean.class)
        throw new AssertionError("Should not reach here");

    // map option name to platform level/name
    OptionKey key = SocketOptionRegistry.findOption(name, family);
    if (key == null)
        throw new AssertionError("Option not found");

    boolean mayNeedConversion = (family == UNSPEC);
    int value = getIntOption0(fd, mayNeedConversion, key.level(), key.name());

    if (type == Integer.class) {
        return Integer.valueOf(value);
    } else {
        return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
    }
}
 
Example #26
Source File: AsynchronousSocketChannelImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.TCP_NODELAY);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #27
Source File: AsynchronousSocketChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.TCP_NODELAY);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #28
Source File: Net.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
                              SocketOption<?> name)
    throws IOException
{
    Class<?> type = name.type();

    if (type == SocketFlow.class) {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA"));
        }
        SocketFlow flow = SocketFlow.create();
        ExtendedOptionsImpl.getFlowOption(fd, flow);
        return flow;
    }

    // only simple values supported by this method
    if (type != Integer.class && type != Boolean.class)
        throw new AssertionError("Should not reach here");

    // map option name to platform level/name
    OptionKey key = SocketOptionRegistry.findOption(name, family);
    if (key == null)
        throw new AssertionError("Option not found");

    boolean mayNeedConversion = (family == UNSPEC);
    int value = getIntOption0(fd, mayNeedConversion, key.level(), key.name());

    if (type == Integer.class) {
        return Integer.valueOf(value);
    } else {
        return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
    }
}
 
Example #29
Source File: AsynchronousSocketChannelImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.TCP_NODELAY);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}
 
Example #30
Source File: DatagramChannelImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_BROADCAST);
    set.add(StandardSocketOptions.IP_TOS);
    set.add(StandardSocketOptions.IP_MULTICAST_IF);
    set.add(StandardSocketOptions.IP_MULTICAST_TTL);
    set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
    if (ExtendedOptionsImpl.flowSupported()) {
        set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
    }
    return Collections.unmodifiableSet(set);
}