On Friday 14 August 2009 09:47:50 Gabriel Rossetti wrote: > Gabriel Rossetti wrote: 8< ------------------------------------------ > > Actually, the original code didn't have the sock.setblocking(0), the > problem I am trying to find is that the server does have > sock.setblocking(0) (I can't change that) and it is getting the same > error as my client has with the sock.setblocking(0), except it gets it > on the accept() call. I tried modifying my code to be like this : > > def sendMessage(host, port, msg): > > if isinstance(msg, unicode): > msg = msg.encode("utf-8") > > burstSize = 4096 > > sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > sock.connect((host, port)) > while msg: > sent = sock.send(msg[:burstSize]) > print "Sending %d bytes..." % sent > if sent == 0: > raise RuntimeError, "socket connection broken" > msg = msg[burstSize:] > sock.close() > > thinking maybe if I send small parts it would work better but this does > not seem to change anything. > How are large msgs sent w/ a socket in python to a non-blocking server? > The msg I'm trying to send is 175213 bytes long.
Google for netstring, and also look at sock.sendall instead of send. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list