W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2010

Web Sockets API, buffer handling after the connection is closed

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Thu, 18 Feb 2010 14:56:16 +0200
Message-ID: <4B7D38F0.8090705@helsinki.fi>
To: public-webapps@w3.org, Ian Hickson <ian@hixie.ch>
Hi,

I wonder why send() needs to buffer anything after the connection is 
closed. bufferedAmount is defined: "If the connection is closed, this 
attribute's value will only increase with each call to the send() method 
(the number does not reset to zero once the connection closes)"

Why not clear the buffer right after dispatching close event and then
throw if send() is called, or something similar?

Or is the current behavior there just so that the example works;
send new data whenever socket.bufferedAmount == 0. (Though the send may 
not actually send the data ever)

The example could be a bit different
var socket = new WebSocket('ws://game.example.com:12010/updates');
socket.onopen = function () {
   setInterval(function() {
     if (socket.readyState == WebSocket.OPEN && socket.bufferedAmount == 0)
       socket.send(getUpdateData());
   }, 50);
};



-Olli
Received on Thursday, 18 February 2010 12:56:57 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:37 GMT