当前位置: 首页>>代码示例>>Java>>正文


Java ChannelException类代码示例

本文整理汇总了Java中io.netty.channel.ChannelException的典型用法代码示例。如果您正苦于以下问题:Java ChannelException类的具体用法?Java ChannelException怎么用?Java ChannelException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ChannelException类属于io.netty.channel包,在下文中一共展示了ChannelException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
@Override
        protected void initChannel(SocketChannel ch) throws Exception {
            try {
                ch.config().setOption(ChannelOption.IP_TOS, 0x18);
//                ch.config().setOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024);
//                ch.config().setOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024);
            } catch (ChannelException ex) {
                // IP_TOS not supported by platform, ignore
            }
            ch.config().setAllocator(PooledByteBufAllocator.DEFAULT);
            
            PacketRegistry r = new PacketRegistry();

            ch.pipeline().addLast(new HttpServerCodec());
            ch.pipeline().addLast(new HttpObjectAggregator(65536));
            ch.pipeline().addLast(new WebSocketHandler());
            ch.pipeline().addLast(new PacketDecoder(r));
            ch.pipeline().addLast(new PacketEncoder(r));
            ch.pipeline().addLast(new ClientHandler(server));
        }
 
开发者ID:AlexMog,项目名称:SurvivalMMO,代码行数:21,代码来源:NetworkManager.java

示例2: initChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
    try {
        ch.config().setOption(ChannelOption.TCP_NODELAY, true);
        ch.config().setOption(ChannelOption.IP_TOS, 0x18);
    } catch (ChannelException ex) {
        // IP_TOS not supported by platform, ignore
    }
    ch.config().setAllocator(PooledByteBufAllocator.DEFAULT);
    
    PacketRegistry r = new PacketRegistry();

    ch.pipeline().addLast("idleStateHandler", new IdleStateHandler(0, 0, 30));
    ch.pipeline().addLast(new HttpServerCodec());
    ch.pipeline().addLast(new HttpObjectAggregator(65536));
    ch.pipeline().addLast(new WebSocketHandler());
    ch.pipeline().addLast(new PacketDecoder(r));
    ch.pipeline().addLast(new PacketEncoder(r));
    ch.pipeline().addLast(mExecutorGroup, "serverHandler", new ClientHandler(mServer));
}
 
开发者ID:FightForSub,项目名称:FFS-PubSub,代码行数:21,代码来源:NetworkManager.java

示例3: initChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
    try {
        ch.config().setOption(ChannelOption.IP_TOS, 0x18);
    } catch (ChannelException ex) {
        // IP_TOS not supported by platform, ignore
    }
    ch.config().setAllocator(PooledByteBufAllocator.DEFAULT);

    ch.pipeline().addLast(new HttpServerCodec());
    ch.pipeline().addLast(new HttpObjectAggregator(65536));
    ch.pipeline().addLast(new WebSocketHandler());
    ch.pipeline().addLast(new PacketDecoder());
    ch.pipeline().addLast(new PacketEncoder());
    ch.pipeline().addLast(new ClientHandler(server));
}
 
开发者ID:CalypsoToolz,项目名称:FPAgar,代码行数:17,代码来源:NetworkManager.java

示例4: initChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
    try {
        ch.config().setOption(ChannelOption.IP_TOS, 0x18);
    } catch (ChannelException ex) {
        // IP_TOS not supported by platform, ignore
    }
    ch.config().setAllocator(PooledByteBufAllocator.DEFAULT);

    ch.pipeline().addLast(new HttpServerCodec());
    ch.pipeline().addLast(new HttpObjectAggregator(65536));
    ch.pipeline().addLast(new Handshaker());
    ch.pipeline().addLast(new WebSocketHandler());
    ch.pipeline().addLast(new PacketDecoder());
    ch.pipeline().addLast(new PacketEncoder());
    ch.pipeline().addLast(new ClientHandler(server));
}
 
开发者ID:ClitherProject,项目名称:Clither-Server,代码行数:18,代码来源:NetworkManager.java

示例5: initChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
@Override
public void initChannel(Channel ch) throws Exception
{
    try
    {
        ch.config().setOption( ChannelOption.IP_TOS, 0x18 );
    } catch ( ChannelException ex )
    {
        // IP_TOS is not supported (Windows XP / Windows Server 2003)
    }
    ch.config().setOption( ChannelOption.TCP_NODELAY, true );
    ch.config().setAllocator( PooledByteBufAllocator.DEFAULT );

    ch.pipeline().addLast( TIMEOUT_HANDLER, new ReadTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
    ch.pipeline().addLast( FRAME_DECODER, new Varint21FrameDecoder() );
    ch.pipeline().addLast( FRAME_PREPENDER, framePrepender );

    ch.pipeline().addLast( BOSS_HANDLER, new HandlerBoss() );
}
 
开发者ID:WaterfallMC,项目名称:Waterfall-Old,代码行数:20,代码来源:PipelineUtils.java

示例6: start

import io.netty.channel.ChannelException; //导入依赖的package包/类
/**
 * Start proxy server
 * */
public void start()
    throws InterruptedException {
  ServerBootstrap serverBootstrap = new ServerBootstrap();
  serverBootstrap.group(_acceptorGroup, _upstreamWorkerGroup);
  serverBootstrap.channelFactory(new ChannelFactory<ServerChannel>() {
    @Override
    public ServerChannel newChannel() {
      return new NioServerSocketChannel();
    }
  });
  serverBootstrap.childHandler(new ProxyInitializer(this));

  //bind
  ChannelFuture future = serverBootstrap.bind(_host, _port);

  //wait for the future
  future.awaitUninterruptibly();
  if (!future.isSuccess()) {
    future.channel().closeFuture().awaitUninterruptibly();
    throw new ChannelException(String.format("Failed to bind to: %s:%d", _host, _port), future.cause());
  } else {
    _allChannels.add(future.channel());
  }
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:28,代码来源:ProxyServer.java

示例7: NioUdtAcceptorChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
protected NioUdtAcceptorChannel(final ServerSocketChannelUDT channelUDT) {
    super(null, channelUDT, OP_ACCEPT);
    try {
        channelUDT.configureBlocking(false);
        config = new DefaultUdtServerChannelConfig(this, channelUDT, true);
    } catch (final Exception e) {
        try {
            channelUDT.close();
        } catch (final Exception e2) {
            if (logger.isWarnEnabled()) {
                logger.warn("Failed to close channel.", e2);
            }
        }
        throw new ChannelException("Failed to configure channel.", e);
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:17,代码来源:NioUdtAcceptorChannel.java

示例8: setBroadcast

import io.netty.channel.ChannelException; //导入依赖的package包/类
@Override
public DatagramChannelConfig setBroadcast(boolean broadcast) {
    try {
        // See: https://github.com/netty/netty/issues/576
        if (broadcast &&
            !javaSocket.getLocalAddress().isAnyLocalAddress() &&
            !PlatformDependent.isWindows() && !PlatformDependent.isRoot()) {
            // Warn a user about the fact that a non-root user can't receive a
            // broadcast packet on *nix if the socket is bound on non-wildcard address.
            logger.warn(
                    "A non-root user can't receive a broadcast packet if the socket " +
                    "is not bound to a wildcard address; setting the SO_BROADCAST flag " +
                    "anyway as requested on the socket which is bound to " +
                    javaSocket.getLocalSocketAddress() + '.');
        }

        javaSocket.setBroadcast(broadcast);
    } catch (SocketException e) {
        throw new ChannelException(e);
    }
    return this;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:23,代码来源:DefaultDatagramChannelConfig.java

示例9: register

import io.netty.channel.ChannelException; //导入依赖的package包/类
static LocalAddress register(
        Channel channel, LocalAddress oldLocalAddress, SocketAddress localAddress) {
    if (oldLocalAddress != null) {
        throw new ChannelException("already bound");
    }
    if (!(localAddress instanceof LocalAddress)) {
        throw new ChannelException("unsupported address type: " + StringUtil.simpleClassName(localAddress));
    }

    LocalAddress addr = (LocalAddress) localAddress;
    if (LocalAddress.ANY.equals(addr)) {
        addr = new LocalAddress(channel);
    }

    Channel boundChannel = boundChannels.putIfAbsent(addr, channel);
    if (boundChannel != null) {
        throw new ChannelException("address already in use by: " + boundChannel);
    }
    return addr;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:21,代码来源:LocalChannelRegistry.java

示例10: AbstractNioChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
/**
 * Create a new instance
 *
 * @param parent            the parent {@link Channel} by which this instance was created. May be {@code null}
 * @param ch                the underlying {@link SelectableChannel} on which it operates
 * @param readInterestOp    the ops to set to receive data from the {@link SelectableChannel}
 */
protected AbstractNioChannel(Channel parent, SelectableChannel ch, int readInterestOp) {
    super(parent);
    this.ch = ch;
    this.readInterestOp = readInterestOp;
    try {
        ch.configureBlocking(false);
    } catch (IOException e) {
        try {
            ch.close();
        } catch (IOException e2) {
            if (logger.isWarnEnabled()) {
                logger.warn(
                        "Failed to close a partially initialized socket.", e2);
            }
        }

        throw new ChannelException("Failed to enter non-blocking mode.", e);
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:27,代码来源:AbstractNioChannel.java

示例11: NioSctpChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
/**
 * Create a new instance
 *
 * @param parent        the {@link Channel} which is the parent of this {@link NioSctpChannel}
 *                      or {@code null}.
 * @param sctpChannel   the underlying {@link SctpChannel}
 */
public NioSctpChannel(Channel parent, SctpChannel sctpChannel) {
    super(parent, sctpChannel, SelectionKey.OP_READ);
    try {
        sctpChannel.configureBlocking(false);
        config = new NioSctpChannelConfig(this, sctpChannel);
        notificationHandler = new SctpNotificationHandler(this);
    } catch (IOException e) {
        try {
            sctpChannel.close();
        } catch (IOException e2) {
            if (logger.isWarnEnabled()) {
                logger.warn(
                        "Failed to close a partially initialized sctp channel.", e2);
            }
        }

        throw new ChannelException("Failed to enter non-blocking mode.", e);
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:27,代码来源:NioSctpChannel.java

示例12: NioUdtAcceptorChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
protected NioUdtAcceptorChannel(EventLoop eventLoop, EventLoopGroup childGroup,
        ServerSocketChannelUDT channelUDT) {
    super(null, eventLoop, childGroup, channelUDT, OP_ACCEPT);
    try {
        channelUDT.configureBlocking(false);
        config = new DefaultUdtServerChannelConfig(this, channelUDT, true);
    } catch (final Exception e) {
        try {
            channelUDT.close();
        } catch (final Exception e2) {
            if (logger.isWarnEnabled()) {
                logger.warn("Failed to close channel.", e2);
            }
        }
        throw new ChannelException("Failed to configure channel.", e);
    }
}
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:18,代码来源:NioUdtAcceptorChannel.java

示例13: AbstractNioChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
/**
 * Create a new instance
 *
 * @param parent         the parent {@link Channel} by which this instance was created. May be {@code null}
 * @param ch             the underlying {@link SelectableChannel} on which it operates
 * @param readInterestOp the ops to set to receive data from the {@link SelectableChannel}
 */
protected AbstractNioChannel(Channel parent, SelectableChannel ch, int readInterestOp) {
    super(parent);
    this.ch = ch;
    this.readInterestOp = readInterestOp;
    try {
        ch.configureBlocking(false);
    } catch (IOException e) {
        try {
            ch.close();
        } catch (IOException e2) {
            if (logger.isWarnEnabled()) {
                logger.warn(
                        "Failed to close a partially initialized socket.", e2);
            }
        }

        throw new ChannelException("Failed to enter non-blocking mode.", e);
    }
}
 
开发者ID:kyle-liu,项目名称:netty4study,代码行数:27,代码来源:AbstractNioChannel.java

示例14: OioDatagramChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
/**
 * Create a new instance from the given {@link MulticastSocket}.
 *
 * @param socket    the {@link MulticastSocket} which is used by this instance
 */
public OioDatagramChannel(EventLoop eventLoop, MulticastSocket socket) {
    super(null, eventLoop);

    boolean success = false;
    try {
        socket.setSoTimeout(SO_TIMEOUT);
        socket.setBroadcast(false);
        success = true;
    } catch (SocketException e) {
        throw new ChannelException(
                "Failed to configure the datagram socket timeout.", e);
    } finally {
        if (!success) {
            socket.close();
        }
    }

    this.socket = socket;
    config = new DefaultDatagramChannelConfig(this, socket);
}
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:26,代码来源:OioDatagramChannel.java

示例15: NioSctpChannel

import io.netty.channel.ChannelException; //导入依赖的package包/类
/**
 * Create a new instance
 *
 * @param parent        the {@link Channel} which is the parent of this {@link NioSctpChannel}
 *                      or {@code null}.
 * @param sctpChannel   the underlying {@link SctpChannel}
 */
public NioSctpChannel(Channel parent, EventLoop eventLoop, SctpChannel sctpChannel) {
    super(parent, eventLoop, sctpChannel, SelectionKey.OP_READ);
    try {
        sctpChannel.configureBlocking(false);
        config = new DefaultSctpChannelConfig(this, sctpChannel);
        notificationHandler = new SctpNotificationHandler(this);
    } catch (IOException e) {
        try {
            sctpChannel.close();
        } catch (IOException e2) {
            if (logger.isWarnEnabled()) {
                logger.warn(
                        "Failed to close a partially initialized sctp channel.", e2);
            }
        }

        throw new ChannelException("Failed to enter non-blocking mode.", e);
    }
}
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:27,代码来源:NioSctpChannel.java


注:本文中的io.netty.channel.ChannelException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。