AbstractBootstrap
AbstractBootstrap
public abstract class AbstractBootstrap<B extends AbstractBootstrap<B,C>,C extends Channel>
extends Object
implements Cloneable
1、辅助类,它使引导一个 Channel 变得容易
2、它支持方法链,以提供一种简单的方法来配置 AbstractBootstrap
3、当不在 ServerBootstrap 上下文中使用时,bind() 方法对无连接传输,如:数据报(UDP)很有用
4、创建一个新的 Channel 并将其绑定
public ChannelFuture bind(int inetPort)
public ChannelFuture bind(String inetHost, int inetPort)
public ChannelFuture bind(InetAddress inetHost, int inetPort)
public ChannelFuture bind(SocketAddress localAddress)
5、设置一个服务器端的 Channel 实现
public B channel(Class<? extends C> channelClass)
6、配置 ServerChannel,允许指定一个 ChannelOption,一旦 Channel 实例被创建,它就被用于 Channel 实例。使用 nul 的值来删除之前设置的 ChannelOption
public <T> B option(ChannelOption<T> option, T value)
ServerBootstrap
public class ServerBootstrap
extends AbstractBootstrap<ServerBootstrap,ServerChannel>
1、允许轻松引导 ServerChannel 的 Bootstrap 子类
2、指定用于父(接受者)和子(客户端)的 EventLoopGroup
public ServerBootstrap group(EventLoopGroup group)
3、为父(接受者)和子(客户端)设置 EventLoopGroup,这些 EventLoopGroup 用来处理 ServerChannel 和 Channel 的所有事件和 I/O
public ServerBootstrap group(EventLoopGroup parentGroup, EventLoopGroup childGroup)
4、允许指定一个 ChannelOption,一旦 Channel 实例被创建(在接受者接受 Channel 后),它就被用于 Channel 实例,使用 null 值来删除之前设置的 ChannelOption
public <T> ServerBootstrap childOption(ChannelOption<T> childOption, T value)
5、设置 ChannelHandler,用于为 Channel 的请求提供服务
public ServerBootstrap childHandler(ChannelHandler childHandler)
Bootstrap
public class Bootstrap
extends AbstractBootstrap<Bootstrap,Channel>
1、使引导一个 Channel 给客户端使用变得容易
2、AbstractBootstrap.bind() 方法在与无连接的传输方式,如:数据报(UDP)相结合时非常有用;对于常规 TCP 连接,请使用提供的 connect() 方法
3、客户端 Channel 连接到服务端 Channel
public ChannelFuture connect(String inetHost, int inetPort)
public ChannelFuture connect(InetAddress inetHost, int inetPort)
public ChannelFuture connect(SocketAddress remoteAddress)
public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress)
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战