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提供的.

Netty Associated -- Channel的更多相关文章

  1. Netty 源码解析(二):Netty 的 Channel

    本文首发于微信公众号[猿灯塔],转载引用请说明出处 接下来的时间灯塔君持续更新Netty系列一共九篇 Netty源码解析(一):开始 当前:Netty 源码解析(二): Netty 的 Channel ...

  2. Netty之Channel*

    Netty之Channel* 本文内容主要参考**<<Netty In Action>> ** 和Netty的文档和源码,偏笔记向. 先简略了解一下ChannelPipelin ...

  3. spark2.1源码分析3:spark-rpc如何实现将netty的Channel隐藏在inbox中

    class TransportServer bootstrap.childHandler(new ChannelInitializer<SocketChannel>() { @Overri ...

  4. spark-rpc是如何实现将netty的Channel隐藏在inbox中的

    class TransportServer bootstrap.childHandler(new ChannelInitializer<SocketChannel>() { @Overri ...

  5. Netty:Channel 建立后消息发送失败

    1. 问题现象 Channel 建立后消息发送失败: ChannelFuture future = DeviceManager.getBootstrap().connect(); deviceChan ...

  6. Netty的Channel

    Channel是一个网络端口连接,或者是可以进行读,写,链接,绑定端口的组件的连接.  Channel就是一个链接,它提供了如下的功能. 1:获取当前链接的状态 2:配置当前链接参数 3:进行read ...

  7. netty笔记-:Channel与ChannelHandlerContext执行write方法的区别

      在netty中有我们一般有两种发送数据的方式,即使用ChannelHandlerContext或者Channel的write方法,这两种方法都能发送数据,那么其有什么区别呢.这儿引用netty文档 ...

  8. Netty:Channel

    上一篇我们通过一个简单的Netty代码了解到了Netty中的核心组件,这一篇我们将围绕核心组件中的Channel来展开学习. Channel的简介 Channel代表着与网络套接字或者能够进行IO操作 ...

  9. 项目系统Netty的Channel和用户之间的关系绑定正确做法,以及Channel通道的安全性方案

    前言 考虑一个功能业务,在web程序中向指定的某个用户进行实时通讯 在Web运用的Socket通讯功能中(如在线客服),为保证点对点通讯.而这个看似简单的根据用户寻到起channel通道实际会碰到不少 ...

随机推荐

  1. Java反射初探 ——“当类也学会照镜子”

    反射的作用 开门见山地说说反射的作用   1.为我们提供了全面的分析类信息的能力 2.动态加载类   我理解的“反射”的意义 (仅个人理解哈)   我理解的java反射机制就是: 提供一套完善而强大的 ...

  2. 【Ray Tracing in One Weekend 超详解】 光线追踪1-3

    学完了插值,我们来学习在场景里面添加一个立体彩色球(三维插值) 按照惯例,先看效果: Chapter4: Adding a sphere 我们又一次面临图形学的主要任务. 我们需要再次回顾coord1 ...

  3. 「WC 2019」数树

    「WC 2019」数树 一道涨姿势的EGF好题,官方题解我并没有完全看懂,尝试用指数型生成函数和组合意义的角度推了一波.考场上只得了 44 分也暴露了我在数数的一些基本套路上的不足,后面的 \(\ex ...

  4. 关于Android4.X的Alertdialog对话框

    最近在做Android4.0的开发,发现AlertDialog相比较以前有了较大变化,就是在触摸对话框边缘外部,对话框消失 于是研究其父类发现,可以设置这么一条属性,当然必须先AlertDialog. ...

  5. 使用Google-Colab训练PyTorch神经网络

    Colaboratory 是免费的 Jupyter 笔记本环境,不需要进行任何设置就可以使用,并且完全在云端运行.关键是还有免费的GPU可以使用!用Colab训练PyTorch神经网络步骤如下: 1: ...

  6. Android记录3--ExpandableListView使用+获取SIM卡状态信息

    Android记录3--ExpandableListView使用+获取SIM卡状态信息 2013年8月9日Android记录 ExpandableListView是一个可以实现下拉列表的控件,大家可能 ...

  7. Android应用开发相关下载资源(2015/08/27更新)

    Android应用开发相关下载资源   官方终于发布了Android Studio正式版,Android Studio将会成为推荐使用的主要Android开发工具.   (1)Android SDK ...

  8. 利用/proc/pid/pagemap将虚拟地址转换为物理地址

    内核文档: Documentation/vm/pagemap.txt pagemap is a new (as of 2.6.25) set of interfaces in the kernel t ...

  9. JavaScript进阶系列04,函数参数个数不确定情况下的解决方案

    本篇主要体验函数参数个数不确定情况下的一个解决方案.先来看一段使用函数作为参数进行计算的实例. var calculate = function(x, y, fn) { return fn(x, y) ...

  10. Android:活动的简单使用

    2.1    活动是什么 活动(Activity)是最容易吸引到用户的地方了,它是一种可以包含用户界面的组件, 主要用于和用户进行交互.一个应用程序中可以包含零个或多个活动,但不包含任何活动的 应用程 ...