Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '21,': 0.07; 'socket': 0.07; 'cc:addr:python-list': 0.09; 'encoding.': 0.09; 'buffering': 0.16; 'exclusion': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.16; '>>>': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'sep': 0.22; 'needed.': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'socket,': 0.29; 'there.': 0.30; 'message.': 0.33; 'safely': 0.33; 'received:google.com': 0.35; 'next': 0.35; 'problem.': 0.35; 'too': 0.36; 'data.': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'anything': 0.38; 'mean': 0.38; 'means': 0.39; 'sure': 0.39; "didn't": 0.39; 'where': 0.40; 'ever': 0.60; 'your': 0.60; '"too': 0.84; 'absolutely': 0.88; 'imagine': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=RGb6gk6LWZkYM8e/Zk2pWQxHaNiYbgd1VL0cRFjoj1E=; b=QhVIap9qBJk0OimJFZ3lX25QviSJWL4b1VgMwlBa3p4gn+iOuZnaupfvvoQdbNSFA8 cWvyPN6SdhqnsfAIROxrWATRwVB6gHy9ST/M7VeYDZXjaPmpdy2KVP2UO40uLisB3By+ n7vqcAAOTa+8H5RCxYZcs4Bx55LAODHUWwAznMLe9VziGzD9stYVE1eRHDVBpjJqwxap fY9DKqQjPQK51/o6+5e6HtuXAsATEkEjUpF8B4nlWeiC9vKagglUbWk1ui6Y3/nXhXr1 7K4XAQ/aTJAjvAT7sVjNiVzI4IVKKHJihyxRIk+NjyCa7U6r2XY6CQr22xlxH0136y93 OstQ== MIME-Version: 1.0 X-Received: by 10.107.36.72 with SMTP id k69mr23197911iok.157.1442825148693; Mon, 21 Sep 2015 01:45:48 -0700 (PDT) In-Reply-To: <871tdsp3ox.fsf@elektro.pacujo.net> References: <20150921062713.GA77399@cskk.homeip.net> <876134p5hw.fsf@elektro.pacujo.net> <871tdsp3ox.fsf@elektro.pacujo.net> Date: Mon, 21 Sep 2015 18:45:48 +1000 Subject: Re: Lightwight socket IO wrapper From: Chris Angelico To: Marko Rauhamaa Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442825151 news.xs4all.nl 23720 [2001:888:2000:d::a6]:46476 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96926 On Mon, Sep 21, 2015 at 6:38 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Mon, Sep 21, 2015 at 5:59 PM, Marko Rauhamaa wrote: >>> You can read a full buffer even if you have a variable-length length >>> encoding. >> >> Not sure what you mean there. Unless you can absolutely guarantee that >> you didn't read too much, or can absolutely guarantee that your >> buffering function will be the ONLY way anything reads from the >> socket, buffering is a problem. > > Only one reader can read a socket safely at any given time so mutual > exclusion is needed. > > If you read "too much," the excess can be put in the application's read > buffer where it is available for whoever wants to process the next > message. Which works only if you have a single concept of "application's read buffer". That means that you have only one place that can ever read data. Imagine a