Am Mittwoch, 4. Mai 2005 20:11 schrieb phil:
> But those packets ( I assume TCP ) are going to stack up somewhere,
> the sender is gonna keep trying and retrying.  In other words
> you are increasing overall load to someone's router and the
> network.

This is not true, as TCP tries to adjust its sending speed at the sender end 
to the receiving speed at the receiver end (it raises speed until packets 
start getting dropped, and when they are, it starts decreasing send speed 
again).

Of course, this requires a proper TCP implementation, but any operating system 
should have one.

What you said, with a sleep(.01) is actually not quite the way to go. What you 
could do is something like the following:

MAX_RATE = 1*1024 # (1k)
MAX_SEND = 1024
data = "blabber"
sent = 0
starttime = time.time() - 0.01
while data:
        curtime = time.time()
        if sent / ( curtime - starttime ) > MAX_RATE:
                time.sleep(0.5)
                continue
        newsent = sock.send(data[:MAX_SEND])
        data = data[newsent:]
        sent += newsent

> Someone correct me if I'm drunk on this.

See above. ;)

-- 
--- Heiko.
listening to: Pearl Jam - Man Of The Hour
  see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/

Attachment: pgpESQ4hxQISX.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to