Skip to content

Instantly share code, notes, and snippets.

@mrtazz
Created November 3, 2009 22:01
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/225491 to your computer and use it in GitHub Desktop.
Save mrtazz/225491 to your computer and use it in GitHub Desktop.
import socket
import time
HOST = 'localhost' # The remote host
PORT = 8888
MSGLEN = 60 * 1000
# create the socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# connect to host and port
s.connect((HOST, PORT))
# say what the server should send
s.send(str(MSGLEN)+"\n\n")
msg = ''
starttime = time.time()
# initialize counter
counter = 0
# get the message in chunks
while True:
chunk = s.recv(1000)
print len(chunk)
print "Packet counter: %d" % counter
counter += 1
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