OK, I'm back with another networking question. I'm trying to seend large amounts of information over TCP (the length of data being given to send() is on the order of 16000 characters in length). Unfortunately on the receiving end, the packets appear to be truncated. So I wrote some code that continuously tries to send bigger and bigger packets until it fails and noticed that it never fails at the same length. I'm not even sure these two things are related, but is there some undocumented (or documented and I missed it) maximum size for data you can pass to send()?
<br><br>the sample code is as follows<br>#server<br>import socket<br><br>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>s.bind(("", 2000))<br>s.listen(0)<br>sock, addrinfo = s.accept()<br>for i in range(2 ** 16):
<br> length = int(sock.recv(16))<br> print "excpecting data of length:", length<br> data = sock.recv(length)<br> print "received data of length:", len(data)<br> print<br>s.close()<br>sock.close()<br><br>
#client<br>import socket<br>import time<br><br>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>s.bind(("", 2001))<br>s.connect(("localhost", 2000))<br>for i in range(2 ** 16):<br> packet = "h" * i
<br> s.send("%16d" % len(packet))<br> print "attempting to send data of length:", len(packet)<br> tmp = s.send(packet)<br> print "actually sent data of length:", tmp<br> print<br> time.sleep(.001)
<br>s.close()<br><br>i just put them in different files and ran them from the command line. Any help or suggestions would be greatly appreciated. Thanks.<br><br><br>-Walker<br clear="all"><br>-- <br>This e-mail is licensed under the Creative Commons Attribution-NoDerivs
2.5 License. To view a copy of this license, visit <a href="http://creativecommons.org/licenses/by-nd/2.5/">http://creativecommons.org/licenses/by-nd/2.5/</a> or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.