This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

bufferedAmount

Summary

The number of bytes of data that have been queued using calls to send() but not yet transmitted to the network.

Property of apis/websocket/WebSocketapis/websocket/WebSocket

Syntax

Note: This property is read-only.

var result = element.bufferedAmount;

Return Value

Returns an object of type unsigned longunsigned long

Examples

var data = new ArrayBuffer(10000000);

// perform some operations on the ArrayBuffer
socket.send(data);

if (socket.bufferedAmount === 0) {
  // the data sent
}
else {
  // the data did not send
}

Notes

This can be used to determine whether the network can handle the data rate you are sending. The value does not reset to zero when the connection is closed; if you keep calling send(), this will continue to climb.

Related specifications

W3C WebSocket Specification
W3C Candidate Recommendation

Attributions