基于帧和基于流的协议 [英] Frame-based and stream-based protocols
问题描述
我正在阅读 WebSocket 规范,它是这样写的:
I am reading WebSocket specification, it's written:
WebSocket 协议的设计原则是应该有最少的帧(唯一存在的帧是使协议基于帧而不是基于流,并支持区分 Unicode 文本和二进制帧).
The WebSocket Protocol is designed on the principle that there should be minimal framing (the only framing that exists is to make the protocol frame-based instead of stream-based and to support a distinction between Unicode text and binary frames).
我不明白 frame-based
和 stream-based
是什么意思.您能否提供它们的示例并对差异进行一些基本解释?
I don't understand what do frame-based
and stream-based
mean. Could you please provide examples of them with some basic explanation of the difference?
推荐答案
简短概述:
基于帧:如果我告诉你我向你发送 8 个字节,我向你发送 6 个字节,你会等待接下来的 2 个字节,然后说这是一条消息".
Frame-Based: If I told you that I'm sending you 8 bytes and I send you 6 bytes, you would wait for the next 2 bytes and than say "this is a message".
基于流:我向您发送 6 个字节.我给你发送 2 个字节.是一个消息吗?两条消息?六个消息?你怎么知道一条消息从哪里开始,另一条从哪里开始?
Stream-Based: I send you 6 bytes. I send you 2 bytes. Is it one message? two messages? six messages? How do you know where one message starts and another begins?
这篇关于基于帧和基于流的协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!