Netty Concepts: Difference between revisions
No edit summary |
|||
Line 22: | Line 22: | ||
"Server" and "client" denote behaviors relative to the network: a "server" binds to a local port and listens for incoming connections, whereas a "client" initiates a network connection to a remote (over the network) process. | "Server" and "client" denote behaviors relative to the network: a "server" binds to a local port and listens for incoming connections, whereas a "client" initiates a network connection to a remote (over the network) process. | ||
Netty uses the pattern introduced by Java NIO of writing the data in blocks, not byte by byte. It uses ByteBuf for that. |
Revision as of 22:54, 15 September 2020
Internal
Overview
Java offers access to network via APIs which historically evolved from blocking to non-blocking. The APIs are quite different, so code that was written for blocking network I/O has to be rewritten for non-blocking network I/O. Netty layers in top of these APIs and exposes a common API regardless of whether the interaction with the network layer is performed in a blocking or non-blocking (preferred) fashion.
High throughput non-blocking I/O. Servers and clients. Channel. ChannelPipeline that holds ChannelHandler instances. ChannelHandler is important because it represents the interface between networking concerns and application business logic. Events. Everything is an event (accept new connection, read data, write data - in this context data is an event). Event lifecycle. Events are processed by EventLoops.
Transport and NIO Transport.
Both the server and the client go through a bootstrapping process. This is where the business logic (ChannelHandlers) is "deployed".
Netty is both a framework and a class library.
The ChannelHandlerContext represents the binding between the ChannelPipeline and its installed handlers.
"Server" and "client" denote behaviors relative to the network: a "server" binds to a local port and listens for incoming connections, whereas a "client" initiates a network connection to a remote (over the network) process.
Netty uses the pattern introduced by Java NIO of writing the data in blocks, not byte by byte. It uses ByteBuf for that.