Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!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; '16,': 0.03; 'subject:: [': 0.04; 'socket': 0.07; 'method,': 0.09; 'methods,': 0.09; 'subject:trying': 0.09; 'api': 0.11; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'roy': 0.16; 'semantics': 0.16; 'send()': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'subject:] ': 0.20; 'cc:addr:python.org': 0.22; 'bytes': 0.24; 'specify': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'function': 0.29; 'am,': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; 'usually': 0.31; 'boundary': 0.31; 'option.': 0.31; 'allows': 0.31; 'file': 0.32; 'becomes': 0.33; 'agree': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'expect': 0.39; 'sure': 0.39; 'either': 0.39; 'how': 0.40; 'first': 0.61; 'smith': 0.68; 'article': 0.77; 'edwards': 0.91; 'write()': 0.91; 'to:none': 0.92; '2013': 0.98 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=9iVcHlv0HY4GbutecuATu72uHEk6CiRIXtfOSjaGoGw=; b=rKEguvPmHfug3EsuJQu0WyOUyBt+DPA3L3+kq3mBByVFjTgdJx9AEsRP/ORl3hvlKE 6VdLonf5y+XEMewjBV6ODdReJ9XATilicn+Es0YI3p6gBLXIDdVc4I2MRKjWes1083ft D/YCDzJIlI4LGXfDIfHNg2gQtHBCUpT6kr/24+g5+/0FECavcBRfqlFu2xIq+s3tdnfo SLVDO/Tp2wubIS9BIlafTjWGm/BFqyfyDzRqm+lTOd7lVUbQopwqie0CcSHZGlqKF4jU l6meLXbxit+BbiCT65UKDRm6eWgQDAg/1SM+hINw4jZ9HlYgsgmPXw+8odo6mZk2YgnI stdw== MIME-Version: 1.0 X-Received: by 10.68.108.194 with SMTP id hm2mr15444622pbb.22.1387123499020; Sun, 15 Dec 2013 08:04:59 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Dec 2013 03:04:58 +1100 Subject: Re: [newbie] trying socket as a replacement for nc 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.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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387123508 news.xs4all.nl 2955 [2001:888:2000:d::a6]:37069 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61952 On Mon, Dec 16, 2013 at 2:51 AM, Roy Smith wrote: > In article , > Grant Edwards wrote: > >> UDP is a a _datagram_ service. Either all the bytes in a write() >> should get sent or none of them. Sending a paritial datagram is _not_ >> a valid option. > > I would agree with the above if you said send() instead of write(). > Python socket objects don't have write() methods, file objects do. You > can wrap a file around a socket with socket.makefile(), but I'm not sure > I would expect the UDP record boundary semantics to be honored once you > did that. The underlying C API allows you, on Unix-like systems at least, to use the standard write() function to send UDP packets (as long as you first connect() - otherwise you need sendto() to specify a destination). I don't usually use that method, but I would expect that one call to write() becomes one UDP packet. How that works with socket.makefile() in Python I have no idea. ChrisA