netty的方法
Netty是一个高性能的网络编程框架,提供了丰富的API和方法,以下是一些常用的方法:
-
bootstrap():启动Netty客户端或服务器。
-
group():指定EventLoopGroup,用于处理网络事件。
-
channel():指定Channel的类型,如NIO、OIO、epoll等。
-
handler():指定ChannelHandler,处理网络事件。
-
option():设置ChannelOption,如TCP_NODELAY和SO_KEEPALIVE等。
-
attr():设置Channel的属性,如remoteAddress和localAddress等。
-
connect():连接到指定的远程服务器。
-
bind():绑定到本地端口,监听连接请求。
-
write():发送数据到远程服务器。
-
flush():将缓冲区的数据发送到远程服务器。
-
close():关闭连接,释放资源。
-
addLast():向ChannelPipeline的尾部添加一个ChannelHandler。
-
addFirst():向ChannelPipeline的头部添加一个ChannelHandler。
-
fireChannelRead():触发ChannelRead事件,通知Pipeline中的下一个ChannelHandler读取数据。
-
fireChannelInactive():触发ChannelInactive事件,通知Pipeline中的下一个ChannelHandler连接关闭。
-
fireExceptionCaught():触发ExceptionCaught事件,通知Pipeline中的下一个ChannelHandler发生异常。
-
read():从Channel读取数据。
-
writeAndFlush():将数据写入缓冲区并发送到远程服务器。
-
alloc():分配ByteBuf缓冲区。
-
flush():将缓冲区的数据发送到远程服务器。
原文地址: https://www.cveoy.top/t/topic/056 著作权归作者所有。请勿转载和采集!