Subject: Re: [hybi] WebSocket closing handshake

From: Ian Hickson <[email-masked]>
Date: Fri, 6 Aug 2010 01:09:57 +0000 (UTC)

On Tue, 18 May 2010, Fumitoshi Ukai (�~\飼�~V~G�~U~O) wrote:
>
> I've question about WebSocket closing handshake. closing handshake is 
> described as follows: [...]
> 
> What means "Send a 0xXX byte to the server" in this context?
>  A) Put 0xXX byte in WebSocket message queue to the server.  "Send 0xXX byte
> to the server" finishes immediately after put in queue.
>  B) Put 0xXX byte in WebSocket message queue to the server, and make sure
> the byte was actually sent to the TCP connection.
>  C) Send 0xXX byte to the server, ignoring WebSocket message queue.

When an implementation is required to send data as part of the WebSocket 
protocol, the implementation may delay the actual transmission 
arbitrarily, e.g. buffering data so as to send fewer IP packets.

I think this means A. I'm not sure what a "WebSocket message queue" is, 
though. I assume you mean the outgoing network buffer(s).

> If this means A, then can we "close the WebSocket connection" (close the TCP
> connection) without sending bytes in WebSocket message queue to the server?

You can only "close the WebSocket connection" where the spec says you can, 
but yes, if the spec says you can "close the WebSocket connection" at a 
point where not all buffered bytes have been sent, then the bytes are 
lost. This generally only happens after a timeout or an error.

(Note that the closing handshake changed slightly in the recent changes to 
the framing. The semantics are the same but the bytes are different.)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'