socket problem

Dave Brueck dave at pythonapocrypha.com
Fri Jul 11 20:42:26 EDT 2003


On Friday 11 July 2003 05:21 pm, Gordon Wetzstein wrote:
> > On Sat, Jul 12, 2003 at 01:05:27AM +0200, Gordon Wetzstein wrote:
> > > Hello everyone,
> > > I have a problem with python sockets. I broadcast a lot of pickled
> > objects
> > > with socket. sendto(...), that works. Ireceive them on the other site
> > with
> > > socket.recvfrom(16384) The pickled objects are smaller (like 10000
> > bytes)
> > > than the max bytes.
> > >
> > > The problem appears if I send too many pickled objects very quickly one
> > > after another, then I only receive a part of the sent objects. I print
> > > them before I send them, they are there but they never reach the
> > > destination. When I do a time.sleep(0.1) (but not lesser than 0.1)
> > > after socket.send() all is good but it's too slow!
> > >
> > > Does anyone know what the problem is? And maybe a solution!
> >
> >   UDP is an inherently unreliable protocol.  If you require reliable data
> > transmission, consider using TCP.
> >
> >   Jp
> >
> > --
>
> But then I can't use braodcast, can I?

Nope. You have to choose between building some reliability on top of UDP or 
tracking your recipients and sending to each one as needed. Even without 
knowing what you're really trying to do, I recommend the latter. :)

-Dave





More information about the Python-list mailing list