tags:

views:

135

answers:

1

hi all ! I use dephi7's client/server socket components to send a file with tfilestream from client to server.

I'am able to get the progress of file received at server side, but at client side, how do i get the progress of the file sent ?

this is how I send the file:

  fstream:=tfilestream.Create(opendialog1.FileName,fmOpenRead);
  clientsocket1.Socket.SendStream(fstream);

Thanks and appreciate for any help.

+4  A: 

It doesn't look like TClientSocket provides any feedback of its progress. I see two alternatives:

  1. Instead of SendStream, use TStream.Read and TClientSocket.Socket.SendBuf in a loop. Read a block of data from the stream and then send it. Repeat until you reach the end of the stream.

  2. Write a TStream descendant class that wraps (or decorates) another stream. Its Read, Write, and Seek methods can simply forward to the wrapped stream, but you can also add some events to the wrapper so you can be notified each time the socket code reads a block of data out of the stream — the SendStream method essentially does the same thing that I described above in the first alternative.

Rob Kennedy