Echo client with deadlock : Socket Client : Network PYTHON examples


PYTHON examples » Network » Socket Client »

 

Echo client with deadlock



import socket, sys
port = 55555
host = 'localhost'

data = "test" 10485760                  40MB of data

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))

byteswritten = 0
while byteswritten < len(data):
    startpos = byteswritten
    endpos = min(byteswritten + 1024, len(data))
    byteswritten += s.send(data[startpos:endpos])
    sys.stdout.write("Wrote %d bytesr" % byteswritten)
    sys.stdout.flush()
    
s.shutdown(1)

print "All data sent."
while 1:
    buf = s.recv(1024)
    if not len(buf):
        break
    sys.stdout.write(buf)


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Network
» Socket Client