The BootStrap, ServerBootStrap
- In Netty, BootStrap is the BootStrap class of the client program
- ServerBootStrap is the server-side bootstrap class
channel
- Netty A component of network communication that can be used to perform network L /O operations.
- You can use Channel to obtain the status of the Channel currently connected to the network
- Network connection configuration parameters (such as receive buffer size) can be obtained via Channel
- A Channel provides asynchronous network I/0 operations (such as establishing connections, reading and writing, and binding ports). An asynchronous call means that any I/0 call will return immediately, and there is no guarantee that the requested I/O operation has completed at the end of the call. By registering listeners on ChannelFuture, callbacks can be called to notify callers of successful, failed, or canceled I/O operations
- Supports associated L /O operations with corresponding handlers
- Connections with different protocols and blocking types have different Channel types. The common Channel types are:
- NioSocketChannel, asynchronous client TCP Socket connection.
- NioServerSocketChannel, an asynchronous server TCP Socket connection. NioDatagramChannel, asynchronous UDP connection.
- NioSctpChannel, asynchronous client Sctp connection.
- NioSctpServerChannel, asynchronous Sctp server side connection, these channels cover UDP and TCP network IO and file I0.
ChannelHandler and its implementation classes
- ChannellnboundHandler is used to handle inbound I/O events.
- ChannelOutboundHandler Is used to process outbound I/O operations.
- ChannellnboundHandlerAdapter handles inbound I/O events.
- ChannelOutboundHandlerAdapter used to handle the outbound I/O operations.
- ChannelDuplexHandler is used to handle inbound and outbound events.
ChannelPipeline provides a container for the ChannelHandler chain. In the case of a client application, events are called outbound if they travel from the client to the server, i.e. the data sent by the client to the server is processed by a series of ChannelOutboundHandlers in the pipeline, and inbound if not
Pipeline
- A ChannelPipeline is a collection of handlers that handle and intercept inbound or outbound events and operations, like a chain running through a Netty. (A ChannelPipeline is a List of ChannelHandlers that handle or intercept Channel inbound events and outbound operations.)
- ChannelPipeline implements an advanced form of interception filter pattern that gives the user complete control over how events are handled and how channelhandlers in a Channel interact with each other
- A Channel contains a ChannelPipeline, which maintains a two-way list of ChannelHandlerContext, And each ChannelHandlerContext is associated with a channelHandler
- Inbound events and outbound events In a bidirectional list, inbound events are passed from the head to the last inbound handler, and outbound events are passed from tail to the last outbound handler. The two types of handlers do not interfere with each other
ChannelHandlerContext
- Saves all context information associated with a Channel, along with a ChannelHandler object
- ChannelHandlerContext contains a specific event handler, ChannelHandler, and the ChannelHandlerContext also binds the corresponding pipeline and Channel information. Easy to call ChannelHandler.
- Commonly used method
- ChannelFuture Close (), close the channel
- ChannelOutboundInvoker Flush (), flush
- ChannelFuture writeAndFlush(Object MSG) to write data to the next ChannelHandler of the current ChannelHandler in the ChannelPipeline to start processing outbound)
Unpooled
ByteBuf
Important method
BossGroup in Handler Corresponds to workerGroup in childHandler