Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7775221
  • 博文数量: 701
  • 博客积分: 2150
  • 博客等级: 上尉
  • 技术积分: 13233
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-29 16:28
个人简介

天行健,君子以自强不息!

文章分类

全部博文(701)

文章存档

2019年(2)

2018年(12)

2017年(76)

2016年(120)

2015年(178)

2014年(129)

2013年(123)

2012年(61)

分类: 架构设计与优化

2015-01-30 11:05:45

I/O模型如下:
+---+      +----+       +----+      +----+                       +----+      +----+
| T |<--->| P1 |<--->| P2 |<--->| P3 |<--->  **  <--->| Pn |<--->| CS |
*---+       *----+       *----+        *----+                       *----+       *----+

T  - Transport level. At this level we store the inbound data into a buffer
     or send the data from the output buffer. This layer may or may not
     have a IOHandler attached. This give us the possibility of having
     stateless communication like a chain of protocols in which HTTP is
     the edge protocol with the outside world. Basically, this layer
     will do I/O whenever a carrier is available.
T - 传输层。
    在这一层中,我们将流入的数据存储到一个buffer中,或将输出buffer中的数据发送出去。
    这一层,可以有,也可以没有附带的IOHandler, 
    这样可以在处理无状态连接,如以HTTP为对外服务的边缘协议的协议链时很有用。
    基本上,无论一个载体是否有效,这一层都可以用做I/O.

P1 to Pn - Protocol levels. At this levels we do packing/unpacking of the
           data provided either by the transport level or by the previous
           protocol. This way we can stack multiple protocol on top of each
           other. For example we could have RTMP over HTTP, or RTMP over some
           kind of compressing protocol over base64 over HTTP
P1 to Pn - 协议层。
           在这一层中,将会封装/拆封闭由传输层或前一个协议提供的数据。
           依据这样的方式,我们可以实现将协议间的堆叠。
           例如,可以将RTMP堆叠在HTTP上,或将RTMP堆叠在某些压缩协议之上后再堆叠base64,再堆叠HTTP。
CS - Connection state. At this level we do the business logic of the connection.
     All the data passed in and out of this level is translated relative to the
    business logic of the connection. For example in a RTMP connection this
     layer will receive only RTMP messages.
CS - 连接状态
     在这一层中,我们需要处理连接的业务逻辑。
     所有输入或输出这一层的数据都会被转换与连接相关的业务逻辑。
     例如,RTMP连接在这一层中只会收到RTMP消息。

下面是一些可能协议链:
1. TCP <--> HTTP <--> XMLRPC <--> Application Server State
2. TCP <--> RTMP <--> RTMP Connection State
3. TCP <--> HTTP <--> RTMP <--> RTMP Connection State
4. TCP <--> Encription <--> RTMP <--> RTMP Connection State
5. TCP <--> HTTP <--> Encription <--> RTMP <--> RTMP Connection State
...
很显然,在实际使用中,上面的协议链并不会都有用,这些只是示例而已。
阅读(2574) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~