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


Groups > comp.lang.python > #63540

Re: Learning python networking

References <22d58d76-f2c2-4a1d-8049-3409ac4665d3@googlegroups.com> <CAPTjJmr-4HbCjqfDjTrjLzvoE4BYr6_OS=BBqRLFg4_BtV4iSw@mail.gmail.com>
Date 2014-01-08 15:53 -0800
Subject Re: Learning python networking
From Dan Stromberg <drsalists@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5210.1389225196.18130.python-list@python.org> (permalink)

Show all headers | View raw


Nice response Chris.  Seriously.

On Wed, Jan 8, 2014 at 3:29 PM, Chris Angelico <rosuav@gmail.com> wrote:
> One extremely critical point about your protocol. TCP is a stream -
> you don't have message boundaries. You can't depend on one send()
> becoming one recv() at the other end. It might happen to work when you
> do one thing at a time on localhost, but it won't be reliable on the
> internet or when there's more traffic. So you'll need to delimit
> messages; I recommend you use one of two classic ways: either prefix
> it with a length (so you know how many more bytes to receive), or
> terminate it with a newline (which depends on there not being a
> newline in the text).

Completely agree, and I'll point out
http://stromberg.dnsalias.org/~dstromberg/bufsock.html , which makes
it a little easier to deal with delimiters like newlines or null
termination.

> Another rather important point, in two halves. You're writing this for
> Python 2, and you're writing with no Unicode handling. I strongly
> recommend that you switch to Python 3 and support full Unicode.

Agreed.  It's time modernize.  Don't leave out people on the other
side of the world for no reason other than a modicum of convenience
for the developer.

> Using Python 3.4 (which isn't yet
> stable, but you can download betas) also gives you an asyncio module,
> but I'd leave that aside for the moment; first figure out threading,
> it's likely to be easier.

Personally, I don't like asynchronous I/O, EG twisted.  It tends to
give very complex, uniprocessor solutions to problems, even when those
problems have quite simple, alternative solutions.  I'd rather just
accept and fork in most cases, with or without multiprocessing.

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


Thread

Learning python networking Paul Pittlerson <menkomigen6@gmail.com> - 2014-01-08 14:27 -0800
  Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-09 10:29 +1100
    Re: Learning python networking Paul Pittlerson <menkomigen6@gmail.com> - 2014-01-15 02:37 -0800
      Re: Learning python networking Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-15 11:11 +0000
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-15 23:52 +1100
      Re: Learning python networking "Frank Millman" <frank@chagford.com> - 2014-01-15 15:31 +0200
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 01:07 +1100
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 02:36 +1100
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 03:31 +1100
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 03:32 +1100
      Re: Learning python networking William Ray Wing <wrw@mac.com> - 2014-01-15 11:43 -0500
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 04:07 +1100
      Re: Learning python networking William Ray Wing <wrw@mac.com> - 2014-01-15 11:25 -0500
  Re: Learning python networking Dan Stromberg <drsalists@gmail.com> - 2014-01-08 15:53 -0800
  Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-09 11:07 +1100
  Re: Learning python networking Dan Stromberg <drsalists@gmail.com> - 2014-01-08 19:49 -0800
    Re: Learning python networking Alister <alister.ware@ntlworld.com> - 2014-01-09 11:32 +0000
  Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-09 15:20 +1100

csiph-web