Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.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.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; '21,': 0.07; 'prefix': 0.07; 'cc:addr:python-list': 0.09; '16-bit': 0.09; "hasn't": 0.15; '"got': 0.16; 'all"': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'seconds,': 0.16; 'sequencing': 0.16; 'tcp': 0.16; 'udp,': 0.16; 'well-known': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'example.': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'dropped': 0.22; 'problem:': 0.22; 'sep': 0.22; 'am,': 0.23; 'passing': 0.23; 'header:In-Reply- To:1': 0.24; 'mon,': 0.24; "doesn't": 0.26; 'example': 0.26; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'sequence': 0.27; 'embed': 0.29; 'starts': 0.29; 'there.': 0.30; 'usually': 0.33; 'stands': 0.33; 'handle': 0.34; 'add': 0.34; 'server': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'protocol': 0.35; 'but': 0.36; 'should': 0.36; '(and': 0.36; 'heard': 0.36; 'subject:: ': 0.37; 'one,': 0.37; 'monitor': 0.38; 'mean': 0.38; 'end': 0.39; 'does': 0.39; 'build': 0.40; 'field': 0.60; 'address': 0.61; 'back': 0.62; 'matter': 0.63; 'fire': 0.63; 'great': 0.63; 'within': 0.64; 'limit': 0.65; 'chrisa': 0.84; 'inherent': 0.84; 'to:none': 0.91; 'alone.': 0.91; 'dennis': 0.91; 'fragment': 0.91; 'responses': 0.93 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=S7/YtkuXJCfLLjxTxJc+bhhXh84h7Cs5g8AtwiaDt7g=; b=djnEDLPI0lZ2Q1J73ElCGVEbC0NdSFtkmOLE/vEMvgO9M8b+fCSJiy72/acGb6iEMV aI7w8JoVioRFbF/NCq7ZRLj9lu3lV8TvSifSrJoFQ8qskyWX5euRweJdSRBOVvjHgFrz AF7AfZEkN0nvLAbkTiY786zzjNtW88ZQThqNJW7Nsuz1xeiY7w1gwYi7DOxaGdlNd3Xc mHV83rdaz/+qqSLdDriNXdFiqL/KH38vMKNBecuqXIqQ5XKW5Cqn7duqDSs4TMDVoBOP whAr9N7VAha4/d3rqHysdDGSF8x/nEDNDP/U+gCkJeXEAJ9B77sKK8mpzA7KXGTmqTEb LnYg== MIME-Version: 1.0 X-Received: by 10.50.50.198 with SMTP id e6mr8351051igo.13.1442795693875; Sun, 20 Sep 2015 17:34:53 -0700 (PDT) In-Reply-To: References: Date: Mon, 21 Sep 2015 10:34:53 +1000 Subject: Re: Lightwight socket IO wrapper From: Chris Angelico 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442795696 news.xs4all.nl 23856 [2001:888:2000:d::a6]:58668 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 5207 X-Received-Body-CRC: 3269259259 Xref: csiph.com comp.lang.python:96905 On Mon, Sep 21, 2015 at 10:19 AM, Dennis Lee Bieber wrote: > Even if the IP layer has to fragment a UDP packet to meet limits of the > transport media, it should put them back together on the other end before > passing it up to the UDP layer. To my knowledge, UDP does not have a size > limit on the message (well -- a 16-bit length field in the UDP header). But > since it /is/ "got it all" or "dropped" with no inherent confirmation, one > would have to embed their own protocol within it -- sequence numbers with > ACK/NAK, for example. Problem: if using LARGE UDP packets, this protocol > would mean having LARGE resends should packets be dropped or arrive out of > sequence (and since the ACK/NAK could be dropped too, you may have to > handle the case of a duplicated packet -- also large). > 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? UDP is great when order doesn't matter and each packet stands entirely alone. DNS is a well-known example - the question "What is the IP address for www.rosuav.com?" doesn't in any way affect the question "What is the mail server for gmail.com?", so you fire off UDP packets for each one, and get responses whenever you get them. UDP's also perfect for a heartbeat system - you send out a packet every however-often, and if the monitor hasn't heard from you in X seconds, it starts alerting people. No need for responses of any kind there. But for working with a stream, I usually find it's a lot easier to build on top of TCP than UDP. ChrisA