Created
November 3, 2009 21:57
-
-
Save mrtazz/225486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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