WebSocket - 关闭框架
WebSocket - Close Frame
websocket RFC 声明如下:
If an endpoint receives a Close frame and did not previously send a Close frame, the endpoint MUST send a Close frame in response.
后面还提到:
The server MUST close the underlying TCP connection immediately;
当服务器启动关闭握手时有意义,因为在从客户端检索关闭帧响应时,服务器可以执行 TCP 关闭。
从客户端开始关闭握手时会发生什么?客户端是否应该重新发送某种类型的消息来指示服务器端点执行 TCP 关闭?还是服务器应该在检索到关闭帧时执行 tcp 关闭?
如您所述,RFC 说:
If an endpoint receives a Close frame and did not previously send a Close frame, the endpoint MUST send a Close frame in response.
这适用于服务器和客户端。因此,当 Close 源自 Client 时,将发生以下情况:
- 客户端发送
Close
帧
- 服务器收到
Close
帧并将其回显给客户端,因为它自己没有发送帧
- 服务器关闭其 TCP 连接(它必须在发送
Close
帧后立即执行此操作)
- 客户端关闭了它的 TCP 连接。它可以在收到来自服务器的回显
Close
后直接执行此操作,也可以等到服务器最后关闭它(由于连接状态发生变化,它会知道这一点)
Should the client resent some type of message to instruct the server endpoint to do a tcp close?
(a) 这正是 CLOSE FRAME 消息的用途,并且 (b) 不,服务器必须根据您引用的文本立即关闭 TCP 连接。
or should the server do a tcp close on retrieval of a close frame?
这正是它所说的。当然是在向客户发送关闭帧之后。
websocket RFC 声明如下:
If an endpoint receives a Close frame and did not previously send a Close frame, the endpoint MUST send a Close frame in response.
后面还提到:
The server MUST close the underlying TCP connection immediately;
当服务器启动关闭握手时有意义,因为在从客户端检索关闭帧响应时,服务器可以执行 TCP 关闭。
从客户端开始关闭握手时会发生什么?客户端是否应该重新发送某种类型的消息来指示服务器端点执行 TCP 关闭?还是服务器应该在检索到关闭帧时执行 tcp 关闭?
如您所述,RFC 说:
If an endpoint receives a Close frame and did not previously send a Close frame, the endpoint MUST send a Close frame in response.
这适用于服务器和客户端。因此,当 Close 源自 Client 时,将发生以下情况:
- 客户端发送
Close
帧 - 服务器收到
Close
帧并将其回显给客户端,因为它自己没有发送帧 - 服务器关闭其 TCP 连接(它必须在发送
Close
帧后立即执行此操作) - 客户端关闭了它的 TCP 连接。它可以在收到来自服务器的回显
Close
后直接执行此操作,也可以等到服务器最后关闭它(由于连接状态发生变化,它会知道这一点)
Should the client resent some type of message to instruct the server endpoint to do a tcp close?
(a) 这正是 CLOSE FRAME 消息的用途,并且 (b) 不,服务器必须根据您引用的文本立即关闭 TCP 连接。
or should the server do a tcp close on retrieval of a close frame?
这正是它所说的。当然是在向客户发送关闭帧之后。