Re: WebSocket API - server initiated close

On Thu, 14 Mar 2013, Zhong Yu wrote:
> 
> If a client app connects to a server through WebSocket API, and server 
> sends a close frame, how is the client app notified?

You get a 'close' event on the WebSocket object.


> Does the client stack automatically respond with a close frame, then 
> raise a "close" event?

Whether a close frame is sent or not depends on various things, e.g. 
whether one was received from the server.


> Meanwhile, if the client app is invoking send() while the server close 
> frame arrives, what happens? The paragraph about "bufferedAmount" 
> implies that send() won't fail, is that correct?

Since the processing of an incoming close frame is handled in a task, it 
cannot be synchronous with a send() call. For specific details, see the 
exact algorithm described here:

   http://www.whatwg.org/html/#dom-websocket-send

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

Received on Friday, 9 August 2013 22:05:51 UTC