Netty網絡抽象層組件:
- Channel—Sockets
- EventLoop—Control flow, multithreading, concurrency
- ChannelFuture—Asynchronous notification
Interface Channel
Netty’s Channel interface provides an API that greatly reduces the complexity of working directly with Sockets.
Interface EventLoop
The EventLoop defines Netty’s core abstraction for handling events that occur during the lifetime of a connection
Interface ChannelFuture
As we’ve explained, all I/O operations in Netty are asynchronous. Because an opera- tion may not return immediately, we need a way to determine its result at a later time
ChannelHandler and ChannelPipeline
manage the flow of data and execute an application’s processing logic
Interface ChannelHandler
serves as the container for all application logicInterface ChannelPipeline
A ChannelPipeline provides a container for a chain of ChannelHandlers and defines an API for propagating the flow of inbound and outbound events along the chain
Encoders and decoders
When you send or receive a message with Netty, a data conversion takes place. An inbound message will be decoded; that is, converted from bytes to another format, typi- cally a Java object. If the message is outbound, the reverse will happen: it will be encoded to bytes from its current format.