Skip to content

Instantly share code, notes, and snippets.

@mrtazz
Created November 3, 2009 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrtazz/225486 to your computer and use it in GitHub Desktop.
Save mrtazz/225486 to your computer and use it in GitHub Desktop.
import socket
import time
HOST = 'localhost' # The remote host
PORT = 9999
MSGLEN = 100 * 1000 * 1000
# create the socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# connect to host and port
s.connect((HOST, PORT))
# say what the server should send
s.send('Stuff to send')
msg = ''
starttime = time.time()
# initialize counter
counter = 0
# get the message in chunks
while len(msg) < MSGLEN:
chunk = s.recv(1000)
msg = msg + chunk
#print len(chunk)
#print "Packet counter: %d" % counter
counter += 1
print len(msg)
s.close()
endtime = time.time()
print (endtime - starttime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment