码迷,mamicode.com
首页 > Web开发 > 详细

RFC 6455-The WebSocket Protocal部分内容

时间:2020-03-28 23:40:36      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:view   管理   hat   web   dep   格式   tail   prot   rfc   

1. Web的基本数据帧格式:

WebSocket在建立连接之后,通信的基本数据格式如下图(来源RFC6455-5.2),没有Http请求那么多固定的报文,且不用重复建立连接,所以通信效率高:

技术图片

 

2. Websocket是如何管理连接的?

RFC6455-5.5给出了答案,协议定义了Control Frame。

WebSocket的控制帧有:Close、Ping、Pong。其中Close是发起关闭请求;Ping是通信发起方确认链路是否畅通的报文;Pong是通信接收方回应链路是否畅通的报文。

对应数据帧中的opcode位(Close 0x8, Ping 0x9, Pong 0xA).

3. Http与Websocket的区别与联系:

Http与websocket是两个完全不同的协议,都是基于TCP的。两者唯一的联系是WebSocket利用Http进行握手;具体说明请看RFC6455-1.7

1.7.  Relationship to TCP and HTTP

   _This section is non-normative._

   The WebSocket Protocol is an independent TCP-based protocol.  Its
   only relationship to HTTP is that its handshake is interpreted by
   HTTP servers as an Upgrade request.

   By default, the WebSocket Protocol uses port 80 for regular WebSocket
   connections and port 443 for WebSocket connections tunneled over
   Transport Layer Security (TLS) [RFC2818].

 

RFC 6455-The WebSocket Protocal部分内容

标签:view   管理   hat   web   dep   格式   tail   prot   rfc   

原文地址:https://www.cnblogs.com/lfri/p/12589938.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!