资源描述:
《websocket协议的握手和数据帧》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、WebSocket协议的握手和数据帧WebSocket是定义服务器和客户端如何通过Web通信的一种网络协议。协议是通信的议定规则。组成互联网的协议组由IETF(互联网工程任务组)发布。IETF发布评议请求(RequestforComments,RFC),精确地规定了协议(包括RFC6455):WebSocket协议。RFC6455于2011年12月发布,包含了实现WebSocket客户端和服务器时必须遵循的规则。websocket基本上是一个很简单的协议,主要流程非常少,实现起来也很简单。为简单起见,下
2、面只分析握手和数据帧的报文.一.握手(handshake).握手协议由客户端发起,服务器响应,一来一回就完成了.基本上是为了兼容现有的http基础设施.下面是一个客户端发起的握手请求:474554202F20485454502F312E310D0AGET./.HTTP/1.1.. 557067726164653A20776562736F636BUpgrade:.websock 65740D0A436F6E6E656374696F6E3A20et..Connection:. 557067726164650
3、D0A486F73743A2031Upgrade..Host:.1 39322E3136382E382E3132383A31333092.168.8.128:130 300D0A4F726967696E3A206E756C6C0D0..Origin:.null. 0A507261676D613A206E6F2D63616368.Pragma:.no-cach 650D0A43616368652D436F6E74726F6Ce..Cache-Control 3A206E6F2D63616368650D0A
4、5365632D:.no-cache..Sec- 576562536F636B65742D4B65793A2064WebSocket-Key:.d 33353946646F366F6D79716678795946359Fdo6omyqfxyYF 37596163773D3D0D0A5365632D5765627Yacw==..Sec-Web 536F636B65742D56657273696F6E3A20Socket-Version:. 31330D0A5365632D576562536F636B651
5、3..Sec-WebSocke 742D457874656E73696F6E733A20782Dt-Extensions:.x- 7765626B69742D6465666C6174652D66webkit-deflate-f 72616D650D0A557365722D4167656E74rame..User-Agent 3A204D6F7A696C6C612F352E30202857:.Mozilla/5.0.(W 696E646F7773204E5420362E313B2057indows.NT.
6、6.1;.W 4F57363429204170706C655765624B69OW64).AppleWebKi 742F3533372E333620284B48544D4C2Ct/537.36.(KHTML, 206C696B65204765636B6F2920436872.like.Gecko).Chr 6F6D652F33322E302E313635332E3020ome/32.0.1653.0. 5361666172692F3533372E33360D0A0DSafari/537.36... 0A
7、 otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehas
8、beentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,Ministersand0D0A0D0A,也就是用"rr"收尾,这和http