I tried to create a client server script for sending and receiving some files. The scenario is that initially Server sends automatically a csv file to client, client process the file and sends back an answer file.
When I start receiving the file I can see all the contents of the file but is not doing a break to continue to the next function for sending back the answer file Is server part problem or client or both?
#GET THE WORK FILE with open('received_file.csv', 'wb') as f: print ('file opened') while True: data = s.recv(BUFFER_SIZE) print('receiving data...') print('data=%s', (data)) #data ='' if not data: print('Successfully get the file') break f.write(data) f.close()
Only if I place data=' ' it goes next but shouldn't server sends an empty data packet? It wouldn't work if a received file is over buffer size correct?
while True: print('Starting is ',starting) l = f.read(BUFFER_SIZE) while (l): self.sock.send(l) print('Sending..') l = f.read(BUFFER_SIZE) if not l: f.close() starting = 0 del filenames print('Sending in over..') self.getfile()