tcp/ip os ie
利用 TWinSocketStream 可以做到.
TServerWinSocket serverSocket;
TClientWinSocket clientSocket
TFileStream inFile, outFile;
// 假设各 Stream 都己 created// 在 Server 端
// Client send 一个命令告知 Server 要由 536 bytes 开始传inFile.Position := 536;
wtih TWinSocketStream.Create(serverSocket, 60000) do
begin
CopyFrom(inFile, inFile.Size - inFile.Position + 1);
Free;
end;// 在 Client 端 OnReadEvent 中
memStream = TMemoryStream.Create;
memStream.Size = TOTAL_FILE_SIZE;
memStream.Position := 0;
socketStream := TWinSocketStream.Create(clientSocket, 60000) do
if socketStream.WaitForData(60000) then // give the client 60 seconds writing
socketStream.Read(PCharArray(memStream.Memory)^, TOTAL_FILE_SIZE)
memStream.Position := 0;
outFile.Position := 536;
outFile.CopyFrom(memStream);// 释放全部的对象