com.sun.nio.sctp.SctpStandardSocketOptions Java Examples

The following examples show how to use com.sun.nio.sctp.SctpStandardSocketOptions. 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: DefaultSctpServerChannelConfig.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
@Override
public <T> boolean setOption(ChannelOption<T> option, T value) {
    validate(option, value);

    if (option == ChannelOption.SO_RCVBUF) {
        setReceiveBufferSize((Integer) value);
    } else if (option == ChannelOption.SO_SNDBUF) {
        setSendBufferSize((Integer) value);
    } else if (option == SctpChannelOption.SCTP_INIT_MAXSTREAMS) {
        setInitMaxStreams((SctpStandardSocketOptions.InitMaxStreams) value);
    } else {
        return super.setOption(option, value);
    }

    return true;
}
 
Example #2
Source File: DefaultSctpChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 6 votes vote down vote up
@Override
public <T> boolean setOption(ChannelOption<T> option, T value) {
    validate(option, value);

    if (option == SO_RCVBUF) {
        setReceiveBufferSize((Integer) value);
    } else if (option == SO_SNDBUF) {
        setSendBufferSize((Integer) value);
    } else if (option == SCTP_NODELAY) {
        setSctpNoDelay((Boolean) value);
    } else if (option == SCTP_INIT_MAXSTREAMS) {
        setInitMaxStreams((SctpStandardSocketOptions.InitMaxStreams) value);
    } else {
        return super.setOption(option, value);
    }

    return true;
}
 
Example #3
Source File: DefaultSctpChannelConfig.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
@Override
public <T> boolean setOption(ChannelOption<T> option, T value) {
    validate(option, value);

    if (option == SO_RCVBUF) {
        setReceiveBufferSize((Integer) value);
    } else if (option == SO_SNDBUF) {
        setSendBufferSize((Integer) value);
    } else if (option == SCTP_NODELAY) {
        setSctpNoDelay((Boolean) value);
    } else if (option == SCTP_INIT_MAXSTREAMS) {
        setInitMaxStreams((SctpStandardSocketOptions.InitMaxStreams) value);
    } else {
        return super.setOption(option, value);
    }

    return true;
}
 
Example #4
Source File: DefaultSctpChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSctpNoDelay() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SCTP_NODELAY);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #5
Source File: DefaultSctpChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public SctpChannelConfig setSctpNoDelay(boolean sctpNoDelay) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SCTP_NODELAY, sctpNoDelay);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #6
Source File: DefaultSctpChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public int getSendBufferSize() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SO_SNDBUF);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #7
Source File: DefaultSctpChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public SctpChannelConfig setSendBufferSize(int sendBufferSize) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SO_SNDBUF, sendBufferSize);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #8
Source File: DefaultSctpChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public int getReceiveBufferSize() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SO_RCVBUF);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #9
Source File: DefaultSctpChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public SctpChannelConfig setReceiveBufferSize(int receiveBufferSize) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SO_RCVBUF, receiveBufferSize);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #10
Source File: DefaultSctpChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public SctpStandardSocketOptions.InitMaxStreams getInitMaxStreams() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #11
Source File: DefaultSctpChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public SctpChannelConfig setInitMaxStreams(SctpStandardSocketOptions.InitMaxStreams initMaxStreams) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS, initMaxStreams);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #12
Source File: NettySctpManagementImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
public InitMaxStreams getOptionSctpInitMaxstreams() {
    if (optionSctpInitMaxstreams_MaxInStreams != null && optionSctpInitMaxstreams_MaxOutStreams != null) {
        return SctpStandardSocketOptions.InitMaxStreams.create(optionSctpInitMaxstreams_MaxInStreams,
                optionSctpInitMaxstreams_MaxOutStreams);
    } else {
        return null;
    }
}
 
Example #13
Source File: SctpLimitStreamsTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 5000)
public void testSctpInitMaxstreams() throws Exception {
    EventLoopGroup loop = newEventLoopGroup();
    try {
        ServerBootstrap serverBootstrap = new ServerBootstrap();
        serverBootstrap.group(loop)
                .channel(serverClass())
                .option(ChannelOption.SO_REUSEADDR, true)
                .option(SctpChannelOption.SCTP_INIT_MAXSTREAMS,
                        SctpStandardSocketOptions.InitMaxStreams.create(1, 1))
                .localAddress(new InetSocketAddress(0))
                .childHandler(new ChannelInboundHandlerAdapter());

        Bootstrap clientBootstrap = new Bootstrap()
                .group(loop)
                .channel(clientClass())
                .option(SctpChannelOption.SCTP_INIT_MAXSTREAMS,
                        SctpStandardSocketOptions.InitMaxStreams.create(112, 112))
                .handler(new ChannelInboundHandlerAdapter());

        Channel serverChannel = serverBootstrap.bind()
                .syncUninterruptibly().channel();
        SctpChannel clientChannel = (SctpChannel) clientBootstrap.connect(serverChannel.localAddress())
                .syncUninterruptibly().channel();
        assertEquals(1, clientChannel.association().maxOutboundStreams());
        assertEquals(1, clientChannel.association().maxInboundStreams());
        serverChannel.close().syncUninterruptibly();
        clientChannel.close().syncUninterruptibly();
    } finally {
        loop.shutdownGracefully();
    }
}
 
Example #14
Source File: DefaultSctpChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public SctpChannelConfig setInitMaxStreams(SctpStandardSocketOptions.InitMaxStreams initMaxStreams) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS, initMaxStreams);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #15
Source File: DefaultSctpChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public SctpStandardSocketOptions.InitMaxStreams getInitMaxStreams() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #16
Source File: DefaultSctpChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public SctpChannelConfig setReceiveBufferSize(int receiveBufferSize) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SO_RCVBUF, receiveBufferSize);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #17
Source File: DefaultSctpChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public int getReceiveBufferSize() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SO_RCVBUF);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #18
Source File: DefaultSctpChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public SctpChannelConfig setSendBufferSize(int sendBufferSize) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SO_SNDBUF, sendBufferSize);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #19
Source File: DefaultSctpChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public int getSendBufferSize() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SO_SNDBUF);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #20
Source File: DefaultSctpChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public SctpChannelConfig setSctpNoDelay(boolean sctpNoDelay) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SCTP_NODELAY, sctpNoDelay);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #21
Source File: DefaultSctpChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSctpNoDelay() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SCTP_NODELAY);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #22
Source File: DefaultSctpServerChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public SctpServerChannelConfig setInitMaxStreams(SctpStandardSocketOptions.InitMaxStreams initMaxStreams) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS, initMaxStreams);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #23
Source File: DefaultSctpServerChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public SctpStandardSocketOptions.InitMaxStreams getInitMaxStreams() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #24
Source File: DefaultSctpServerChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public SctpServerChannelConfig setReceiveBufferSize(int receiveBufferSize) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SO_RCVBUF, receiveBufferSize);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #25
Source File: DefaultSctpServerChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public int getReceiveBufferSize() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SO_RCVBUF);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #26
Source File: DefaultSctpServerChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public SctpServerChannelConfig setSendBufferSize(int sendBufferSize) {
    try {
        javaChannel.setOption(SctpStandardSocketOptions.SO_SNDBUF, sendBufferSize);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
Example #27
Source File: DefaultSctpServerChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public int getSendBufferSize() {
    try {
        return javaChannel.getOption(SctpStandardSocketOptions.SO_SNDBUF);
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
 
Example #28
Source File: SctpServerChannelImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static Set<SctpSocketOption<?>> defaultOptions() {
    HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(1);
    set.add(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
    return Collections.unmodifiableSet(set);
}
 
Example #29
Source File: SctpServerChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static Set<SctpSocketOption<?>> defaultOptions() {
    HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(1);
    set.add(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
    return Collections.unmodifiableSet(set);
}
 
Example #30
Source File: SctpServerChannelImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static Set<SctpSocketOption<?>> defaultOptions() {
    HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(1);
    set.add(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
    return Collections.unmodifiableSet(set);
}