![]() |
How to avoid the transfer TCPServer TCPClient
How to avoid the receive (if not exists) or discard file (if exists)
My code is Send code:
Delphi-Quellcode:
Receive code
...
TCPAggiorna.SendCmd ('aggiorna'); for i:=0 to ElencoFile.Count - 1 do begin FStream := TFileStream.Create(ElencoFile[i], fmOpenRead, fmShareDenyWrite); TCPAggiorna.IOHandler.WriteLn(ExtractFileName(ElencoFile[i])); TCPAggiorna.IOHandler.LargeStream := True; TCPAggiorna.IOHandler.Write(FStream, 0, True); FreeAndNil(FStream); end; TCPAggiorna.IOHandler.WriteLn('Finito'); ....
Delphi-Quellcode:
Dir := AppPath;
FileName:=''; i:=202; repeat inc(i); FileName:= ASender.Context.Connection.IOHandler.ReadLn; if (FileName <> 'Finito') then begin if (FileExists(Dir+FileName)) then begin // Insert here the code to discard file ASender.Context.Connection.IOHandler.WriteLn (IntToStr(i)+' File '+FileName+' received'); end else begin FStream := TFileStream.Create(Dir+FileName, fmCreate, fmOpenWrite); ASender.Context.Connection.IOHandler.LargeStream := True; ASender.Context.Connection.IOHandler.ReadStream(FStream, -1); FreeAndNil(FStream); ASender.Context.Connection.IOHandler.WriteLn (IntToStr(i)+' File '+FileName+' discarded'); end; end; until FileName='Finito'; |
Re: How to avoid the transfer TCPServer TCPClient
|
Re: How to avoid the transfer TCPServer TCPClient
The receiver doesn't know where the file's data ends and the filename of the next file starts.
You have to send the length of each file. Otherwise it's impossible to separate the TCP/IP datastream into different files.
Code:
filename<CR><LF>filelength<CR><LF>file content
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:59 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz