Hi!

Hi!
I am did simple a file transfer using Indy. When file is small (ie. 1Kb) the client side receives a 0 byte, but this is due because not getting bytes.

Not best solution, but I dont know any other, the receive loop is:

LFilename := IdTCPClient1.IOHandler.ReadLn; //
while IdTCPClient1.IOHandler.CheckForDataOnSource do
begin
IdTCPClient1.IOHandler.ReadStream(Strm, -1, false);
Application.ProcessMessages;
end;

When get small files I only receive the LFilename and CheckForDataOnSource if False so my stream is closed without any bytes. If I force ReadStream() by ignoring CheckForDataOnSource it will hang, because it is false.

This works fine for large files, but fail to small files because CheckForDataOnSource() gets to False.

Comments

  1. Bilâl SEZER Actually I just fixed it. On the server side I did:
    FileSize := TStream(AContext.Data).Size;
    AContext.Connection.IOHandler.LargeStream := True;
    AContext.Connection.IOHandler.Write(TStream(AContext.Data), FileSize, True);

    Previously the FileSize was not there, it was fixed as 0. Now it works.
    Thank you but anyway I dont trust my solution :)

    ReplyDelete

Post a Comment