Example usage for io.netty.channel.sctp SctpChannelOption SCTP_NODELAY

List of usage examples for io.netty.channel.sctp SctpChannelOption SCTP_NODELAY

Introduction

In this page you can find the example usage for io.netty.channel.sctp SctpChannelOption SCTP_NODELAY.

Prototype

ChannelOption SCTP_NODELAY

To view the source code for io.netty.channel.sctp SctpChannelOption SCTP_NODELAY.

Click Source Link

Usage

From source file:com.barchart.netty.server.stream.SCTPServer.java

License:BSD License

@Override
public ServerBootstrap bootstrap() {
    return super.bootstrap().childOption(SctpChannelOption.SCTP_NODELAY, true);
}

From source file:com.cmz.sctp.multihoming.SctpMultiHomingEchoClient.java

License:Apache License

public static void main(String[] args) throws Exception {
    // Configure the client.
    EventLoopGroup group = new NioEventLoopGroup();
    try {/*from   ww w.j av  a 2s. c  o  m*/
        Bootstrap b = new Bootstrap();
        b.group(group).channel(NioSctpChannel.class).option(SctpChannelOption.SCTP_NODELAY, true)
                .handler(new ChannelInitializer<SctpChannel>() {
                    @Override
                    public void initChannel(SctpChannel ch) throws Exception {
                        ch.pipeline().addLast(
                                //                             new LoggingHandler(LogLevel.INFO),
                                new SctpEchoClientHandler());
                    }
                });

        InetSocketAddress localAddress = SocketUtils.socketAddress(CLIENT_PRIMARY_HOST, CLIENT_PORT);
        InetAddress localSecondaryAddress = SocketUtils.addressByName(CLIENT_SECONDARY_HOST);

        InetSocketAddress remoteAddress = SocketUtils.socketAddress(SERVER_REMOTE_HOST, SERVER_REMOTE_PORT);

        // Bind the client channel.
        ChannelFuture bindFuture = b.bind(localAddress).sync();

        // Get the underlying sctp channel
        SctpChannel channel = (SctpChannel) bindFuture.channel();

        // Bind the secondary address.
        // Please note that, bindAddress in the client channel should be done before connecting if you have not
        // enable Dynamic Address Configuration. See net.sctp.addip_enable kernel param
        channel.bindAddress(localSecondaryAddress).sync();

        // Finish connect
        ChannelFuture connectFuture = channel.connect(remoteAddress).sync();

        // Wait until the connection is closed.
        connectFuture.channel().closeFuture().sync();
    } finally {
        // Shut down the event loop to terminate all threads.
        group.shutdownGracefully();
    }
}

From source file:com.cmz.sctp.SctpEchoClient.java

License:Apache License

public static void main(String[] args) throws Exception {
    // Configure the client.
    EventLoopGroup group = new NioEventLoopGroup();
    try {//w w  w  .j a v a 2  s .  c o  m
        Bootstrap b = new Bootstrap();
        b.group(group).channel(NioSctpChannel.class).option(SctpChannelOption.SCTP_NODELAY, true)
                .handler(new ChannelInitializer<SctpChannel>() {
                    @Override
                    public void initChannel(SctpChannel ch) throws Exception {
                        ch.pipeline().addLast(
                                //new LoggingHandler(LogLevel.INFO),
                                new SctpEchoClientHandler());
                    }
                });

        // Start the client.
        ChannelFuture f = b.connect(HOST, PORT).sync();

        // Wait until the connection is closed.
        f.channel().closeFuture().sync();
    } finally {
        // Shut down the event loop to terminate all threads.
        group.shutdownGracefully();
    }
}

From source file:com.hop.hhxx.example.sctp.multihoming.SctpMultiHomingEchoClient.java

License:Apache License

public static void main(String[] args) throws Exception {
    // Configure the client.
    EventLoopGroup group = new NioEventLoopGroup();
    try {/*from www  .j  a  va  2s.  c o  m*/
        Bootstrap b = new Bootstrap();
        b.group(group).channel(NioSctpChannel.class).option(SctpChannelOption.SCTP_NODELAY, true)
                .handler(new ChannelInitializer<SctpChannel>() {
                    @Override
                    public void initChannel(SctpChannel ch) throws Exception {
                        ch.pipeline().addLast(
                                //                             new LoggingHandler(LogLevel.INFO),
                                new SctpEchoClientHandler());
                    }
                });

        InetSocketAddress localAddress = new InetSocketAddress(CLIENT_PRIMARY_HOST, CLIENT_PORT);
        InetAddress localSecondaryAddress = InetAddress.getByName(CLIENT_SECONDARY_HOST);

        InetSocketAddress remoteAddress = new InetSocketAddress(SERVER_REMOTE_HOST, SERVER_REMOTE_PORT);

        // Bind the client channel.
        ChannelFuture bindFuture = b.bind(localAddress).sync();

        // Get the underlying sctp channel
        SctpChannel channel = (SctpChannel) bindFuture.channel();

        // Bind the secondary address.
        // Please note that, bindAddress in the client channel should be done before connecting if you have not
        // enable Dynamic Address Configuration. See net.sctp.addip_enable kernel param
        channel.bindAddress(localSecondaryAddress).sync();

        // Finish connect
        ChannelFuture connectFuture = channel.connect(remoteAddress).sync();

        // Wait until the connection is closed.
        connectFuture.channel().closeFuture().sync();
    } finally {
        // Shut down the event loop to terminate all threads.
        group.shutdownGracefully();
    }
}

From source file:com.mastfrog.scamper.ChannelConfigurer.java

License:Open Source License

/**
 * Initialize a client sctp channel//from ww w  . j a v a 2s.  c  om
 *
 * @param b The bootstrap
 * @return The bootstrap
 */
protected Bootstrap init(Bootstrap b) {
    b = b.group(group).channel(NioSctpChannel.class).option(SctpChannelOption.SCTP_NODELAY, true)
            .option(ChannelOption.ALLOCATOR, alloc).handler(new LoggingHandler(LogLevel.INFO)).handler(init);
    return b;
}

From source file:com.mastfrog.scamper.SctpServerAndClientBuilder.java

License:Open Source License

/**
 * Create a new builder./*from w  w w .  j  a va 2s  .  c  o  m*/
 *
 * @param settingsName Settings (port and other configuration that can be
 * found using Guice's &#064;Named annotation) are looked up by merging
 * properties files named $settingsName.properties in /etc /opt/local/etc,
 * ~/ and ./ if they are present. If command-line arguments are passed to
 * the build methods, these can be overridden there
 */
public SctpServerAndClientBuilder(String settingsName) {
    Checks.notNull("settingsName", settingsName);
    this.settingsName = settingsName;
    option(SctpChannelOption.SCTP_NODELAY, true);
}

From source file:io.aos.netty5.sctp.NioSctpEchoClient.java

License:Apache License

public void run() throws Exception {
    // Configure the client.
    EventLoopGroup group = new NioEventLoopGroup();
    try {/*from   w  ww  .  ja va 2 s.co m*/
        Bootstrap b = new Bootstrap();
        b.group(group).channel(NioSctpChannel.class).option(SctpChannelOption.SCTP_NODELAY, true)
                .handler(new ChannelInitializer<SctpChannel>() {
                    @Override
                    public void initChannel(SctpChannel ch) throws Exception {
                        ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new SctpEchoClientHandler());
                    }
                });

        // Start the client.
        ChannelFuture f = b.connect(host, port).sync();

        // Wait until the connection is closed.
        f.channel().closeFuture().sync();
    } finally {
        // Shut down the event loop to terminate all threads.
        group.shutdownGracefully();
    }
}

From source file:io.aos.netty5.sctp.OioSctpEchoClient.java

License:Apache License

public void run() throws Exception {
    // Configure the client.
    EventLoopGroup group = new OioEventLoopGroup();
    try {/*from   w w  w  . j  a v  a 2  s. co  m*/
        Bootstrap b = new Bootstrap();
        b.group(group).channel(OioSctpChannel.class).option(SctpChannelOption.SCTP_NODELAY, true)
                .handler(new ChannelInitializer<SctpChannel>() {
                    @Override
                    public void initChannel(SctpChannel ch) throws Exception {
                        ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new SctpEchoClientHandler());
                    }
                });

        // Start the client.
        ChannelFuture f = b.connect(host, port).sync();

        // Wait until the connection is closed.
        f.channel().closeFuture().sync();
    } finally {
        // Shut down the event loop to terminate all threads.
        group.shutdownGracefully();
    }
}

From source file:org.mobicents.protocols.sctp.netty.NettyAssociationImpl.java

License:Open Source License

private void applySctpOptions(Bootstrap b) {
    b.option(SctpChannelOption.SCTP_NODELAY, this.management.getOptionSctpNodelay());
    b.option(SctpChannelOption.SCTP_DISABLE_FRAGMENTS, this.management.getOptionSctpDisableFragments());
    b.option(SctpChannelOption.SCTP_FRAGMENT_INTERLEAVE, this.management.getOptionSctpFragmentInterleave());
    b.option(SctpChannelOption.SCTP_INIT_MAXSTREAMS, this.management.getOptionSctpInitMaxstreams());
    b.option(SctpChannelOption.SO_SNDBUF, this.management.getOptionSoSndbuf());
    b.option(SctpChannelOption.SO_RCVBUF, this.management.getOptionSoRcvbuf());
    b.option(SctpChannelOption.SO_LINGER, this.management.getOptionSoLinger());
}

From source file:org.mobicents.protocols.sctp.netty.NettyServerImpl.java

License:Open Source License

private void applySctpOptions(ServerBootstrap b) {
    b.childOption(SctpChannelOption.SCTP_NODELAY, this.management.getOptionSctpNodelay());
    b.childOption(SctpChannelOption.SCTP_DISABLE_FRAGMENTS, this.management.getOptionSctpDisableFragments());
    b.childOption(SctpChannelOption.SCTP_FRAGMENT_INTERLEAVE,
            this.management.getOptionSctpFragmentInterleave());
    b.childOption(SctpChannelOption.SCTP_INIT_MAXSTREAMS, this.management.getOptionSctpInitMaxstreams());
    b.childOption(SctpChannelOption.SO_SNDBUF, this.management.getOptionSoSndbuf());
    b.childOption(SctpChannelOption.SO_RCVBUF, this.management.getOptionSoRcvbuf());
    b.childOption(SctpChannelOption.SO_LINGER, this.management.getOptionSoLinger());
}