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


Groups > comp.lang.python > #96907 > unrolled thread

Re: Lightwight socket IO wrapper

Started byCameron Simpson <cs@zip.com.au>
First post2015-09-21 11:55 +1000
Last post2015-09-22 07:47 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Lightwight socket IO wrapper Cameron Simpson <cs@zip.com.au> - 2015-09-21 11:55 +1000
    Re: Lightwight socket IO wrapper Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-09-22 07:47 +0000

#96907 — Re: Lightwight socket IO wrapper

FromCameron Simpson <cs@zip.com.au>
Date2015-09-21 11:55 +1000
SubjectRe: Lightwight socket IO wrapper
Message-ID<mailman.16.1442801735.28679.python-list@python.org>
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...)

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.

Cheers,
Cameron Simpson <cs@zip.com.au>

If you lie to the compiler, it will get its revenge.    - Henry Spencer

[toc] | [next] | [standalone]


#96974

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2015-09-22 07:47 +0000
Message-ID<slrnn021t8.eij.grahn+nntp@frailea.sa.invalid>
In reply to#96907
On Mon, 2015-09-21, Cameron Simpson 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...)
>
> 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. 

There's also the impact on your application. With TCP you need to
consider that you may block when reading or writing, and you'll be
using threads and/or a state machine driven by select() or something.
UDP is more fire-and-forget.

> 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.

That, and also (again) the impact on the application.  With UDP you
can easily end up wasting a lot of time reading tiny datagrams one by
one.  It has often been a performance bottleneck for me, with certain
UDP-based protocols which cannot pack multiple application-level
messages into one datagram.

Although perhaps you tend not to use Python in those situations.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web