类io.netty.channel.sctp.nio.NioSctpServerChannel源码实例Demo

下面列出了怎么用io.netty.channel.sctp.nio.NioSctpServerChannel的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: netty-4.1.22   文件: SctpTestPermutation.java
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;
}
 
源代码2 项目: netty4.0.27Learn   文件: SctpTestPermutation.java
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;
}
 
源代码3 项目: netty-cookbook   文件: SimpleSctpServer.java
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();
    }
}
 
源代码4 项目: netty-cookbook   文件: SimpleSctpServer.java
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();
    }
}
 
源代码5 项目: netty-4.1.22   文件: SctpEchoServer.java
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();
    }
}
 
源代码6 项目: mpush   文件: GatewayServer.java
@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();
}
 
源代码7 项目: netty4.0.27Learn   文件: SctpEchoServer.java
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();
    }
}
 
源代码8 项目: sctp   文件: NettyServerImpl.java
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()));
        }
    }
}
 
 类所在包
 类方法
 同包方法