W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2010

[whatwg] WebSocket bufferedAmount includes overhead or not

From: Jonas Sicking <jonas@sicking.cc>
Date: Tue, 30 Mar 2010 23:38:21 -0700
Message-ID: <q2s63df84f1003302338xc2ba30d7re5964c938351ff68@mail.gmail.com>
On Tue, Mar 30, 2010 at 9:56 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> On 3/30/10 10:22 AM, Jonas Sicking wrote:
>>
>> Making it implementation dependent is likely to lead to website
>> incompatibilities. Such as:
>>
>> ws = new WebSocket(...);
>> ws.onopen = function() {
>> ? ws.send(someString);
>> ? if (ws.bufferedAmount> ?X) {
>> ? ? doStuff();
>
> Can bufferedAmount not change due to data actually hitting the network
> during the execution of this code? ?As in, will all the someString data be
> buffered immediately after that send() call?

I would have expected bufferedAmount to only change as a result of an
event being posted to the main event loop. We generally try to avoid
"racy" variables since people don't expect them. Consider for example

if (ws.bufferedAmount > X) {
  setUpSomeState();
}

try {
  doOtherThings();
}
finally {
  if (ws.bufferedAmount > X) {
    cleanUpState();
  }
}

I'd imagine most JS developers to expect the cleanup to always happen
if the setup did.

/ Jonas
Received on Tuesday, 30 March 2010 23:38:21 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:22 UTC