problem with sockets and transferring binary files
gagsl-py2 at yahoo.com.ar
Wed Jun 3 07:29:55 CEST 2009
En Wed, 03 Jun 2009 01:54:02 -0300, <thebiggestbangtheory at gmail.com>
> I am a python newbie. I am now progressing to writing a
> network app in python to learn more about it. [...]
> Surprisingly, the sha1 hash of the encrypted data before it is sent
> from server is different from the encrypted file data received by the
> data = connection.recv(10000000) # receive up to 10000000
recv returns *up* *to* 10000000 bytes: maybe only one byte.
You'll have to keep recv'ing the pieces until you get an empty string
(when client closes the connection), or send the file size first and then
the actual data.
> buf = open(currentpath+'received-container.tar.gz', 'w')
If you're on Linux it doesn't matter, but the 'w' above should be 'wb' for
a binary file.
> def send_to_sender(cipher, servername):
Similar to recv above: send() might not send the whole string at once (try
More information about the Python-list