I'm trying to send a binary file from a client that runs on ironPython 2.7.4 to a server that runs on cpython 2.7.6 on a linuxbox. I followed this example, however when the server starts writing the file (first call to f.write
), I get an Error:
TypeError: must be string or buffer, not int
Here the I think relevant pieces of the code.
server:
def recvall(self, count):
msgparts = []
while count > 0:
newbuf = self.conn.recv(count)
if not newbuf: return None
msgparts.append(newbuf)
count -= len(newbuf)
#print "%i bytes left" % count
return "".join(msgparts)
#receive file, write out
f = open(fname, 'wb')
chunk = self.recvall(1024)
while (chunk):
f.write(1024) #<-- error happens here.
chunk = self.recvall(1024)
f.close()
client:
f = open(fname, 'rb')
chunk = f.read(1024)
while (chunk):
self.conn.send(chunk)
chunk = f.read(1024)
f.close()
conn
is the socket connection - this works, I can transfer pickled dicts successfully.
Any hints?
thanks and regards, Dominic