[whatwg] WebSockets: why boolean return value for send()?
Ian Hickson
ian at hixie.ch
Thu Aug 5 18:01:47 PDT 2010
On Thu, 15 Apr 2010, Simon Pieters wrote:
>
> WebSocket send():
>
> [[
> The send(data) method transmits data using the connection. ... If the
> connection is established, and the string has no unpaired surrogates, and the
> WebSocket closing handshake has not yet started, then the user agent must send
> data using the WebSocket. If the data cannot be sent, e.g. because it would
> need to be buffered but the buffer is full, the user agent must close the
> WebSocket connection. The method must then return true if the connection is
> still established (and the data was queued or sent successfully), or false if
> the connection is closing or closed (e.g. because the user agent just had a
> buffer overflow and failed to send the data, or because the WebSocket closing
> handshake has started).
> ]]
>
> Why does send() have a boolean return value? What problem does it solve?
>
> It seems to me that we don't want send() to wait with returning until
> data has been sent over the network, or until the connection has been
> closed. If the script wants to check if the connection is closing or
> closed, it can read readyState instead of reading the return value of
> send(). If a script wants to check if the data was sent, it can read
> bufferedAmount or let the server respond.
>
> As I see it, the boolean return value of send() is imposing
> implementation complexity and slowness in script execution without
> solving any problem. If I've missed something, please explain.
> Otherwise, I think send() should just update bufferedAmount and have an
> early void return and do the sending or closing connection async.
I couldn't work out why send() sends a boolean (the e-mails sent at the
time of the change talk about everything but the return value) so I've
removed this feature.
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list