A nexus to a network socket or a component which is capable of I/O operations such as read, write, connect, and bind.
一个网络套接字或组件的枢纽, 用来进行 I/O 操作, 例如 read, write, connect, bind.
A channel provides a user:
一个Channel的提供给用户的东西有:
- the current state of the channel (e.g. is it open? is it connected?),
- channel目前的状态(例如 是否是打开的? 是否是连接的?)
- the configuration parameters of the channel (e.g. receive buffer size),
- channel的配置参数(例如接收缓存的大小)
- the I/O operations that the channel supports (e.g. read, write, connect, and bind), and
- channel支持的I/O操作(例如 read, write, connect, bind)
- the ChannelPipeline which handles all I/O events and requests associated with the channel.
- 一个ChannelPipeline, 这个pipeline用来处理所有的I/O时间和域channel相关的请求
All I/O operations are asynchronous.
所有I/O操作都是异步的
All I/O operations in Netty are asynchronous. It means any I/O calls will return immediately with no guarantee that the requested I/O operation has been completed at the end of the call. Instead, you will be returned with a ChannelFuture instance which will notify you when the requested I/O operation has succeeded, failed, or canceled.
在Netty中所有I/O操作都是异步的. 这意味着任何的IO调用都会立即返回, 但是无法保证在IO调用完成以后,请求的IO操作已经完成了.取而代之的是, 你会被返回一个ChannelFuture实例, 它在请求的IO操作成功, 失败, 取消的时候会通知你.
Channels are hierarchical
Channel是分等级的
A Channel can have a parent depending on how it was created. For instance, a SocketChannel, that was accepted by ServerSocketChannel, will return the ServerSocketChannel as its parent on parent().
一个Channel可以有一个父母, 这取决于他是如何被创建的. 例如, 一个被ServerSocketChannel接受的SocketChannel, 调用它的parent()方法会返回他的父母 -- ServerSocketChannel
The semantics of the hierarchical structure depends on the transport implementation where the Channel belongs to. For example, you could write a new Channel implementation that creates the sub-channels that share one socket connection, as BEEP and SSH do.
分级结构的语义取决于Channel从属的传输实现.例如,你可以写一个新的Channel实现, 它创建一个子channel, 并共享一个socket连接, 就像 BEEP和SSH那样.
Downcast to access transport-specific operations
向下转型来访问特定传输协议操作
Some transports exposes additional operations that is specific to the transport. Down-cast the Channel to sub-type to invoke such operations. For example, with the old I/O datagram transport, multicast join / leave operations are provided by DatagramChannel.
一些传输协议暴露了一些这个协议特有的操作.可以将Channel向下转型为一个子类型来调用这些操作. 例如, 旧的IO数据报传输协议, 组播 join/ leave 操作都是由 DatagramChannel提供的.