Path: csiph.com!goblin3!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'api.': 0.04; 'socket': 0.07; 'wrapper': 0.07; 'added.': 0.09; 'bsd': 0.09; 'high-level': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sockets': 0.09; 'thread': 0.10; 'python': 0.10; 'python.': 0.11; 'applies': 0.15; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'socket.': 0.16; 'threading': 0.16; 'bytes': 0.18; 'helper': 0.18; ';-)': 0.18; 'library': 0.20; 'preferred': 0.20; 'simpler': 0.22; 'trying': 0.22; 'bit': 0.23; 'module': 0.25; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'fine': 0.28; 'initial': 0.28; 'convenience': 0.29; 'guarantees': 0.29; 'idea,': 0.29; 'so-called': 0.29; 'sure,': 0.29; 'handled': 0.29; 'normally': 0.30; 'extend': 0.31; 'guess': 0.31; 'url:python': 0.33; 'qualify': 0.33; 'message-id:@gmail.com': 0.34; 'handle': 0.34; 'list': 0.34; 'trouble': 0.35; 'something': 0.35; 'but': 0.36; 'should': 0.36; 'instead': 0.36; 'needed': 0.36; 'there': 0.36; 'url:org': 0.36; '(and': 0.36; 'basic': 0.36; 'framework': 0.36; 'modules': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'detail': 0.38; 'guys': 0.38; 'anything': 0.38; 'end': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'some': 0.40; 'save': 0.60; 'your': 0.60; 'back': 0.62; 'here.': 0.62; 'more': 0.63; 'transferred': 0.72; 'received:89': 0.80; 'extra.': 0.84; 'is)': 0.84; 'streams': 0.84; 'improvement': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Akira Li <4kir4.1i@gmail.com> Subject: Re: Lightwight socket IO wrapper Date: Sun, 20 Sep 2015 16:15:07 +0300 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 89.169.229.68 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:ybybjaBxWg3tdR2B1WyACewntsI= 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442754893 news.xs4all.nl 23798 [2001:888:2000:d::a6]:40068 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96875 "James Harris" writes: > I guess there have been many attempts to make socket IO easier to > handle and a good number of those have been in Python. > > The trouble with trying to improve something which is already well > designed (and conciously left as is) is that the so-called improvement > can become much more complex and overly elaborate. That can apply to > the initial idea, for sure, but when writing helper or convenience > functions perhaps it applies more to the temptation to keep adding > just a little bit extra. The end result can be overly elaborate such > as a framework which is fine where such is needed but is overkill for > simpler requirements. > > Do you guys have any recommendations of some *lightweight* additions > to Python socket IO before I write any more of my own? Something built > in to Python would be much preferred over any modules which have to be > added. I had in the back of my mind that there was a high-level > socket-IO library - much as threading was added as a wrapper to the > basic thread module - but I cannot find anything above socket. Is > there any? Does ØMQ qualify as lightweight? > A current specific to illustrate where basic socket IO is limited: it > normally provides no guarantees over how many bytes are transferred at > a time (AFAICS that's true for both streams and datagrams) so the > delimiting of messages/records needs to be handled by the sender and > receiver. I do already handle some of this myself but I wondered if > there was a prebuilt solution that I should be using instead - to save > me adding just a little bit extra. ;-) There are already convenience functions in stdlib such as sock.sendall(), sock.sendfile(), socket.create_connection() in addition to BSD Sockets API. If you want to extend this list and have specific suggestions; see https://docs.python.org/devguide/stdlibchanges.html Or just describe your current specific issue in more detail here.