I send a .txt file(about 87 kbyte size) from a client to a server over TCP with the following code(python):
Client:
f = open(filename, 'r')
while 1:
data = f.read(1024)
if not data:
data='*Endoffile*!'
con.send('%1024s' %data)
f.close()
break
else:
con.send('%1024s' %data)
Server:
f = open(filename,'w')
while 1:
data = c.recv(1045)
if data=='%1024s' %'*Endoffile*!':
f.close()
break
else:
f.write(data)
The problem is that the file received is always cut at the same point(it stops always at the same word when i open it), about 1,6 kbyte smaller than the size of the complete file. Does anyone have a suggestion of what to do?