- 1、本文档共10页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ubuntu下python2.76
windows?Python?2.79, chrome37 firefox35通过
代码是在别人(cddn有人提问)基础上改的, 主要改动了parsedata和sendmessage这2个函数.
改代码参考下面了这段文档. 主要是第5条, 发送的数据长度分别是 8bit和 16bit和 64 bit(即?127, 65535,和2^64-1)三种情况?
发送和收取是一样的, 例如
1.长度小于125时(由于使用126, 127用作标志位.)
2. 数据长度在128-65525之间时,?Payload Length位设为126, 后面额外使用16bit表示长度(前面的126不再是长度的一部分)
3.数据长度在65526-2^64-1之间时,?Payload Length位设为127, 后面额外使用64bit表示长度(前面的127不再是长度的一部分)
Fin (bit 0): determines if this is the last frame in the message. This would be set to 1 on the end of a series of frames, or in a single-frame message, it would be set to 1 as it is both the first and last frame.
RSV1, RSV2, RSV3 (bits 1-3): these three bits are reserved for websocket extensions, and should be 0 unless a specific extension requires the use of any of these bytes.
Opcode (bits 4-7): these four bits deterimine the type of the frame. Control frames communicate WebSocket state, while non-control frames communicate data. The various types of codes include:
x0: continuation frame; this frame contains data that should be appended to the previous frame
x1: text frame; this frame (and any following) contains text
x2: binary frame; this frame (and any following) contains binary data
x3 - x7: non-control reserved frames; these are reserved for possible websocket extensions
x8: close frame; this frame should end the connection
x9: ping frame
xA: pong frame
xB - xF: control reserved frames
Mask (bit 8): this bit determines whether this specific frame uses a mask or not.
Payload Length (bits 9-15, or 16-31, or 16-79): these seven bytes determine the payload length. If the length is 126, the length is actually determined by bits 16 through 31 (that is, the following two bytes). If the length is 127, the length is actually determined by bits 16 through 79 (that is, the following eight bytes).
Masking Key (the following four bytes): this represents the mask, if the Mask bit is set to 1.
Payload Data (the following data): finally, the data. The payload data may be sent over mul
文档评论(0)