Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96908

Re: Lightwight socket IO wrapper

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 <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '21,': 0.07; 'prefix': 0.07; 'terminated': 0.07; 'cc:addr:python-list': 0.09; 'bytes,': 0.09; 'encode': 0.09; 'protocols,': 0.09; 'buffering': 0.16; 'fits': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'guarentee': 0.16; 'interest,': 0.16; 'sequencing': 0.16; 'simpson': 0.16; 'tcp': 0.16; 'udp,': 0.16; 'writes.': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'bytes': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'do.': 0.22; 'ascii': 0.22; 'sep': 0.22; 'am,': 0.23; '(or': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'chris': 0.26; 'packaging': 0.27; 'message-id:@mail.gmail.com': 0.27; 'data,': 0.27; 'another': 0.32; 'usually': 0.33; 'add': 0.34; 'received:google.com': 0.35; 'so,': 0.35; 'but': 0.36; 'should': 0.36; 'subject:: ': 0.37; 'one,': 0.37; 'end': 0.39; 'data': 0.39; 'whatever': 0.39; 'waiting': 0.60; 'care': 0.60; 'your': 0.60; "you'll": 0.61; 'different': 0.63; 'times': 0.63; 'face': 0.64; 'cameron': 0.66; "they're": 0.66; 'counts': 0.81; 'algorithm,': 0.84; 'all!': 0.84; 'chrisa': 0.84; 'packet.': 0.84; 'queued': 0.84; 'to:none': 0.91
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:cc :content-type; bh=hOfxIzc4vtBaogmVe27HoX1ToaW21geq3FbQj9RwLQs=; b=RnhQKAVsTGLcWqq4BuW4U06Wn2o5bvyPX4gx9a8M5Om0vjD/HqYp7/sPiZEtvBFfl7 mg98lvtIi3cphZbC/7vLlp60Le7DaHJmny85gccYQdPAnr2VK5FoDcQe3QAlDIXbSMRU O0b/7gYvl7XlBfWOakc9d7ebVz5gEkWuqSqsNbXcxkqxLTFY4ko0tt8Ppiw1Cf5AzWPY +16hUgkFoJa5MB2c0X16zyUjHZ9vRXHJ3j2FXwTYJVwRnDBNnmIqErm+Hv8Nv43MNdOi MoQL+DJsG6enaj0r57yeGPcoJjrUkwZ5+6vEatFgtQX+O/7PZcmMI3AMnKMGaM0h3y0H HQKQ==
MIME-Version 1.0
X-Received by 10.107.33.81 with SMTP id h78mr22613423ioh.19.1442803203366; Sun, 20 Sep 2015 19:40:03 -0700 (PDT)
In-Reply-To <20150921015514.GA70236@cskk.homeip.net>
References <CAPTjJmpLyuy==kY4hj11pGkRedhBS5vevitmzeDvwz8rQpSSag@mail.gmail.com> <20150921015514.GA70236@cskk.homeip.net>
Date Mon, 21 Sep 2015 12:40:03 +1000
Subject Re: Lightwight socket IO wrapper
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17.1442803211.28679.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1442803211 news.xs4all.nl 23779 [2001:888:2000:d::a6]:43410
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:96908

Show key headers only | View raw


On Mon, Sep 21, 2015 at 11:55 AM, Cameron Simpson <cs@zip.com.au> wrote:
> On 21Sep2015 10:34, Chris Angelico <rosuav@gmail.com> wrote:
>>
>> If you're going to add sequencing and acknowledgements to UDP,
>> wouldn't it be easier to use TCP and simply prefix every message with
>> a two-byte length?
>
>
> Frankly, often yes. That's what I do. (different length encoding, but
> otherwise...)

Out of interest, what encoding? With most protocols, I would prefer to
encode in ASCII digits terminated by end-of-line, but for arbitrary
content you're packaging up, it's usually easier to read 2 bytes (or 4
or whatever you want to specify), then read that many bytes, and
that's your content. No buffering required - you'll never read past
the end of a packet.

> UDP's neat if you do not care if a packet fails to arrive and if you can
> guarentee that your data fits in a packet in the face of different MTUs.
> I like TCP myself, most of the time. Another nice thing about TCP is that
> wil a little effort you get to pack multiple data packets (or partial data
> packets) into a network packet, etc.

Emphatically - a little effort sometimes, and other times no effort at
all! If you write a packet of data, then write another one, and
another, and another, and another, without waiting for responses,
Nagling should combine them automatically. And even if they're not
deliberately queued by Nagle's Algorithm, packets can get combined for
other reasons. So, yeah! Definitely can help a lot with packet counts
on small writes.

ChrisA

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Lightwight socket IO wrapper Chris Angelico <rosuav@gmail.com> - 2015-09-21 12:40 +1000
  Re: Lightwight socket IO wrapper Marko Rauhamaa <marko@pacujo.net> - 2015-09-21 07:39 +0300
    Re: Lightwight socket IO wrapper Chris Angelico <rosuav@gmail.com> - 2015-09-21 14:48 +1000
      Re: Lightwight socket IO wrapper Marko Rauhamaa <marko@pacujo.net> - 2015-09-21 09:56 +0300
    Re: Lightwight socket IO wrapper Michael Ströder <michael@stroeder.com> - 2015-09-21 09:02 +0200
      Re: Lightwight socket IO wrapper Marko Rauhamaa <marko@pacujo.net> - 2015-09-21 10:57 +0300
        Re: Lightwight socket IO wrapper Michael Ströder <michael@stroeder.com> - 2015-09-21 10:29 +0200
          Re: Lightwight socket IO wrapper Marko Rauhamaa <marko@pacujo.net> - 2015-09-21 11:47 +0300
            Re: Lightwight socket IO wrapper MRAB <python@mrabarnett.plus.com> - 2015-09-21 13:26 +0100

csiph-web