io.netty.channel.sctp.nio.NioSctpServerChannel Java Examples
The following examples show how to use
io.netty.channel.sctp.nio.NioSctpServerChannel.
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: SctpTestPermutation.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
static List<BootstrapFactory<ServerBootstrap>> sctpServerChannel() { if (!TestUtils.isSctpSupported()) { return Collections.emptyList(); } List<BootstrapFactory<ServerBootstrap>> list = new ArrayList<BootstrapFactory<ServerBootstrap>>(); // Make the list of ServerBootstrap factories. list.add(new BootstrapFactory<ServerBootstrap>() { @Override public ServerBootstrap newInstance() { return new ServerBootstrap(). group(nioBossGroup, nioWorkerGroup). channel(NioSctpServerChannel.class); } }); list.add(new BootstrapFactory<ServerBootstrap>() { @Override public ServerBootstrap newInstance() { return new ServerBootstrap(). group(oioBossGroup, oioWorkerGroup). channel(OioSctpServerChannel.class); } }); return list; }
Example #2
Source File: SctpTestPermutation.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
static List<BootstrapFactory<ServerBootstrap>> sctpServerChannel() { if (!TestUtils.isSctpSupported()) { return Collections.emptyList(); } List<BootstrapFactory<ServerBootstrap>> list = new ArrayList<BootstrapFactory<ServerBootstrap>>(); // Make the list of ServerBootstrap factories. list.add(new BootstrapFactory<ServerBootstrap>() { @Override public ServerBootstrap newInstance() { return new ServerBootstrap(). group(nioBossGroup, nioWorkerGroup). channel(NioSctpServerChannel.class); } }); list.add(new BootstrapFactory<ServerBootstrap>() { @Override public ServerBootstrap newInstance() { return new ServerBootstrap(). group(oioBossGroup, oioWorkerGroup). channel(OioSctpServerChannel.class); } }); return list; }
Example #3
Source File: SimpleSctpServer.java From netty-cookbook with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventLoopGroup mainLoop = new NioEventLoopGroup(1); EventLoopGroup workerLoop = new NioEventLoopGroup(); try { ChannelFuture f = new ServerBootstrap().group(mainLoop, workerLoop) .channel(NioSctpServerChannel.class) .option(ChannelOption.SO_BACKLOG, 100) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SctpChannel>() { @Override public void initChannel(SctpChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast(new SimpleSctpServerHandler()); } }).bind(PORT).sync(); f.channel().closeFuture().sync(); } finally { mainLoop.shutdownGracefully(); workerLoop.shutdownGracefully(); } }
Example #4
Source File: SimpleSctpServer.java From netty-cookbook with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventLoopGroup mainLoop = new NioEventLoopGroup(1); EventLoopGroup workerLoop = new NioEventLoopGroup(); try { ChannelFuture f = new ServerBootstrap().group(mainLoop, workerLoop) .channel(NioSctpServerChannel.class) .option(ChannelOption.SO_BACKLOG, 100) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SctpChannel>() { @Override public void initChannel(SctpChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast(new SimpleSctpServerHandler()); } }).bind(PORT).sync(); f.channel().closeFuture().sync(); } finally { mainLoop.shutdownGracefully(); workerLoop.shutdownGracefully(); } }
Example #5
Source File: SctpEchoServer.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { // Configure the server. EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup) .channel(NioSctpServerChannel.class) .option(ChannelOption.SO_BACKLOG, 100) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SctpChannel>() { @Override public void initChannel(SctpChannel ch) throws Exception { ch.pipeline().addLast( //new LoggingHandler(LogLevel.INFO), new SctpEchoServerHandler()); } }); // Start the server. ChannelFuture f = b.bind(PORT).sync(); // Wait until the server socket is closed. f.channel().closeFuture().sync(); } finally { // Shut down all event loops to terminate all threads. bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
Example #6
Source File: GatewayServer.java From mpush with Apache License 2.0 | 5 votes |
@Override public ChannelFactory<? extends ServerChannel> getChannelFactory() { if (CC.mp.net.tcpGateway()) return super.getChannelFactory(); if (CC.mp.net.udtGateway()) return NioUdtProvider.BYTE_ACCEPTOR; if (CC.mp.net.sctpGateway()) return NioSctpServerChannel::new; return super.getChannelFactory(); }
Example #7
Source File: SctpEchoServer.java From netty4.0.27Learn with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { // Configure the server. EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup) .channel(NioSctpServerChannel.class) .option(ChannelOption.SO_BACKLOG, 100) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SctpChannel>() { @Override public void initChannel(SctpChannel ch) throws Exception { ch.pipeline().addLast( //new LoggingHandler(LogLevel.INFO), new SctpEchoServerHandler()); } }); // Start the server. ChannelFuture f = b.bind(PORT).sync(); // Wait until the server socket is closed. f.channel().closeFuture().sync(); } finally { // Shut down all event loops to terminate all threads. bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
Example #8
Source File: NettyServerImpl.java From sctp with GNU Affero General Public License v3.0 | 4 votes |
private void initSocket() throws Exception { ServerBootstrap b = new ServerBootstrap(); b.group(this.management.getBossGroup(), this.management.getWorkerGroup()); if (this.ipChannelType == IpChannelType.SCTP) { b.channel(NioSctpServerChannel.class); b.option(ChannelOption.SO_BACKLOG, 100); b.childHandler(new NettySctpServerChannelInitializer(this, this.management)); this.applySctpOptions(b); } else { b.channel(NioServerSocketChannel.class); b.option(ChannelOption.SO_BACKLOG, 100); b.childHandler(new NettyTcpServerChannelInitializer(this, this.management)); } b.handler(new LoggingHandler(LogLevel.INFO)); InetSocketAddress localAddress = new InetSocketAddress(this.hostAddress, this.hostport); // Bind the server to primary address. ChannelFuture channelFuture = b.bind(localAddress).sync(); // Get the underlying sctp channel if (this.ipChannelType == IpChannelType.SCTP) { this.serverChannelSctp = (SctpServerChannel) channelFuture.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 if (this.extraHostAddresses != null) { for (int count = 0; count < this.extraHostAddresses.length; count++) { String localSecondaryAddress = this.extraHostAddresses[count]; InetAddress localSecondaryInetAddress = InetAddress.getByName(localSecondaryAddress); channelFuture = this.serverChannelSctp.bindAddress(localSecondaryInetAddress).sync(); } } if (logger.isInfoEnabled()) { logger.info(String.format("SctpServerChannel bound to=%s ", this.serverChannelSctp.allLocalAddresses())); } } else { this.serverChannelTcp = (NioServerSocketChannel) channelFuture.channel(); if (logger.isInfoEnabled()) { logger.info(String.format("ServerSocketChannel bound to=%s ", this.serverChannelTcp.localAddress())); } } }