Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'mrab': 0.05; 'say,': 0.05; 'happen,': 0.07; 'json': 0.07; 'iterate': 0.09; 'length.': 0.09; 'cc:addr:python-list': 0.10; "wouldn't": 0.11; 'integer.': 0.16; 'wrote:': 0.17; 'feb': 0.19; 'followed': 0.20; "i'd": 0.22; 'cc:2**0': 0.23; 'insert': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; '(which': 0.26; 'am,': 0.27; 'fixed': 0.28; 'chris': 0.28; 'decimal': 0.29; 'character': 0.29; 'probably': 0.29; '11,': 0.33; 'received:172.16': 0.34; 'pm,': 0.35; '12,': 0.36; 'charset:us-ascii': 0.36; 'data': 0.37; 'subject:: ': 0.38; 'space': 0.39; 'your': 0.60; 'first': 0.61; 'header:Message-Id:1': 0.62; 'ever': 0.63; '2013': 0.84; 'received:my': 0.93 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: Python recv loop From: Ihsan Junaidi Ibrahim In-Reply-To: Date: Tue, 12 Feb 2013 09:41:14 +0800 Content-Transfer-Encoding: quoted-printable References: <51190A32.7070105@mrabarnett.plus.com> To: Chris Angelico X-Mailer: Apple Mail (2.1499) Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360633285 news.xs4all.nl 6869 [2001:888:2000:d::a6]:55933 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38714 On Feb 11, 2013, at 11:24 PM, Chris Angelico wrote: > On Tue, Feb 12, 2013 at 2:11 AM, MRAB = wrote: >> I probably wouldn't make it fixed length. I'd have the length in >> decimal followed by, say, "\n". >=20 > Or even "followed by any non-digit". Chances are your JSON data begins > with a non-digit, so you'd just have to insert a space in the event > that you're JSON-encoding a flat integer. (Which might not ever > happen, if you know that your data will always be an object.) >=20 > ChrisA So on the first recv() call, I set the buffer at 1 character and I = iterate over single character until a non-digit character is encountered?