// 设置EventLoopGroup,EventLoopGroup用来处理所有通道的IO事件 public B group(EventLoopGroup group) @SuppressWarnings("unchecked") private B self(){ return (B) this; }
// 设置通道类型 public B channel(Class<? extends C> channelClass) // 使用ChannelFactory来设置通道类型 public B channelFactory(io.netty.channel.ChannelFactory<? extends C> channelFactory) // 设置本地地址,也可以通过bind和connect方法来设定 public B localAddress(SocketAddress localAddress) /** * @see #localAddress(SocketAddress) */ public B localAddress(int inetPort) /** * @see #localAddress(SocketAddress) */ public B localAddress(String inetHost, int inetPort) /** * @see #localAddress(SocketAddress) */ public B localAddress(InetAddress inetHost, int inetPort) // 设置通道选项,如果value为null,则删除设置对应的属性 public <T> B option(ChannelOption<T> option, T value) // 设置属性到Channel,如果value为null,则删除对应的属性 public <T> B attr(AttributeKey<T> key, T value) // 创建一个新的Channel并绑定 public ChannelFuture bind() public ChannelFuture bind(int inetPort) public ChannelFuture bind(String inetHost, int inetPort) public ChannelFuture bind(InetAddress inetHost, int inetPort) public ChannelFuture bind(SocketAddress localAddress) // 设置ChannelHandler用于处理请求事件 public B handler(ChannelHandler handler) // 连接远程通道 public ChannelFuture connect() public ChannelFuture connect(String inetHost, int inetPort) public ChannelFuture connect(InetAddress inetHost, int inetPort) public ChannelFuture connect(SocketAddress remoteAddress)
// 设置EventLoopGroup,EventLoopGroup用来处理所有通道的IO事件 public B group(EventLoopGroup group) public ServerBootstrap group(EventLoopGroup parentGroup, EventLoopGroup childGroup) @SuppressWarnings("unchecked") private B self(){ return (B) this; }
// 设置通道类型 public B channel(Class<? extends C> channelClass) // 使用ChannelFactory来设置通道类型 public B channelFactory(io.netty.channel.ChannelFactory<? extends C> channelFactory) // 设置本地地址,也可以通过bind和connect方法来设定 public B localAddress(SocketAddress localAddress) /** * @see #localAddress(SocketAddress) */ public B localAddress(int inetPort) /** * @see #localAddress(SocketAddress) */ public B localAddress(String inetHost, int inetPort) /** * @see #localAddress(SocketAddress) */ public B localAddress(InetAddress inetHost, int inetPort) // 设置通道选项,如果value为null,则删除设置对应的属性 public <T> B option(ChannelOption<T> option, T value) // 设置子通道选项 public <T> ServerBootstrap childOption(ChannelOption<T> childOption, T value) // 设置属性到Channel,如果value为null,则删除对应的属性 public <T> B attr(AttributeKey<T> key, T value) // 设置子通道属性 public <T> ServerBootstrap childAttr(AttributeKey<T> childKey, T value) // 设置ChannelHandler用于处理请求事件 public B handler(ChannelHandler handler) // 设置子ChannelHandler public ServerBootstrap childHandler(ChannelHandler childHandler) // 创建一个新的Channel并绑定 public ChannelFuture bind() public ChannelFuture bind(int inetPort) public ChannelFuture bind(String inetHost, int inetPort) public ChannelFuture bind(InetAddress inetHost, int inetPort) public ChannelFuture bind(SocketAddress localAddress)