Re: [hybi] Technical feedback. was: Process!

Jamie Lokier <jamie@shareable.org> Wed, 03 February 2010 01:11 UTC

Return-Path: <jamie@shareable.org>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id B3B0F3A6782 for <hybi@core3.amsl.com>; Tue, 2 Feb 2010 17:11:55 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.508
X-Spam-Level:
X-Spam-Status: No, score=-2.508 tagged_above=-999 required=5 tests=[AWL=0.091, BAYES_00=-2.599]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AFYvZOI7uSGe for <hybi@core3.amsl.com>; Tue, 2 Feb 2010 17:11:54 -0800 (PST)
Received: from mail2.shareable.org (mail2.shareable.org [80.68.89.115]) by core3.amsl.com (Postfix) with ESMTP id A58913A63EC for <hybi@ietf.org>; Tue, 2 Feb 2010 17:11:53 -0800 (PST)
Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from <jamie@shareable.org>) id 1NcTnD-0004PX-JZ; Wed, 03 Feb 2010 01:12:31 +0000
Date: Wed, 03 Feb 2010 01:12:31 +0000
From: Jamie Lokier <jamie@shareable.org>
To: Justin Erenkrantz <justin@erenkrantz.com>
Message-ID: <20100203011231.GI32743@shareable.org>
References: <4B62C5FE.8090904@it.aoyama.ac.jp> <Pine.LNX.4.64.1001291134350.22020@ps20323.dreamhostps.com> <4B62E516.2010003@webtide.com> <5c902b9e1001290756r3f585204h32cacd6e64fbebaa@mail.gmail.com> <4B636757.3040307@webtide.com> <BBF3CE06-3276-4A7C-8961-7B3DDEE406D0@apple.com> <4B63DC2D.4090702@webtide.com> <5c902b9e1001292325p423d7e82o9478441893e34523@mail.gmail.com> <Pine.LNX.4.64.1002012348000.3846@ps20323.dreamhostps.com> <5c902b9e1002011659g5e755a06wfd3d681a7ba1ee36@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <5c902b9e1002011659g5e755a06wfd3d681a7ba1ee36@mail.gmail.com>
User-Agent: Mutt/1.5.13 (2006-08-11)
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] Technical feedback. was: Process!
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 03 Feb 2010 01:11:57 -0000

Justin Erenkrantz wrote:
> On Mon, Feb 1, 2010 at 3:48 PM, Ian Hickson <ian@hixie.ch> wrote:
> > On Fri, 29 Jan 2010, Justin Erenkrantz wrote:
> >>
> >> Again, this is why the current draft is so impenetrable (to me) since it
> >> expects that the only person implementing the draft is a client vendor
> >> using synchronous socket methods...which sort of defeats the purpose
> >> when you are trying to write a fully async client...or any type of
> >> server.
> >
> > Could you elaborate on this? I looked for text that assumed synchronous
> > socket methods but couldn't find any. Could you quote the offending text?
> 
> All of them are...such as:
> 
> ---
>           Run these steps.  If at any point during these steps a read is
>           attempted but fails because the Web Socket connection is
>           closed, then abort.
> 
>           1.  Let /length/ be zero.
> 
>           2.  _Length_: Read a byte, let /b/ be that byte.
> 
>           3.  Let /b_v/ be integer corresponding to the low 7 bits of
>               /b/ (the value you would get by _and_ing /b/ with 0x7F).
> 
>           4.  Multiply /length/ by 128, add /b_v/ to that result, and
>               store the final result in /length/.
> 
>           5.  If the high-order bit of /b/ is set (i.e. if /b/ _and_ed
>               with 0x80 returns 0x80), then return to the step above
>               labeled _length_.
> 
>           6.  Read /length/ bytes.
> 
>           7.  Discard the read bytes.
> ---
> 
> Greg pointed out issues as to what "send" or "receive" means -
> buffering, etc, etc.
> 
> The algorithmic descriptions can only be precisely followed when you
> write a synchronous client (or server) - the algorithms for an network
> async read or write framework would appear hugely different.  Again, I
> think this challenges the usefulness of specifying the protocol in
> pseudo-code when many (optimized?) implementations won't be able to
> follow those same algorithms.  -- justin

To be honest, I don't see a big problem with the draft in this area.

But perhaps I already have a clear idea how I would implement it and
it's not clear to someone doing it from scratch.

You just have to assume there are buffers.  "send" means queuing bytes
in your output buffer (it's up to the implementation when it actually
sends them), and "receive" means reading them from your input buffer
(they will be read in blocks, no doubt).  "is closed" means "if
you read EOF at this point in the stream", not "is closed" :-)

There is no other meaningful way to interpret it.

Maybe it just needs to say the implementation can use buffering, and
everywhere in the document which mentions reading and writing, it can
be reading and writing the buffers.

Looking at the above, it would be quite a bit clearer to talk about
reading the end of the input (EOF, TCP FIN) than "if the connection is
closed", as the latter has several ambiguous meanings, and you don't
actually want to abort parsing when you know the socket is closed, if
you still have bytes to read from your buffer

-- Jamie