I think you wrong.
The simple send/recv stream do not have loop.
No, I'm right.
Put your cursor on SendStream( and press Alt+up arrow. Then press Ctrl+Shift+Down arrow
You see it says InternalSendStream()
Again Alt+Up arrow and Ctrl+Shift+Down arrow and you are in the InternalSendStream.
You see a loop there so that EVERYTHING in the stream is send.
The WithSize of the function call is true (so size of stream is send first).
After that you have a repeat loop with until yr <= 0 and yr is the result of Stream.read() which will be 0 if the complete stream is read.
SO
NEVER EVER put a loop around SendStream because then you might have the problem that the file is transferred multiple times.
(especially if the data isn't written to disk yet)
The loop is absolutely not needed and can cause serious trouble if not everything is directly written to the disk.
But now I can use the ~streamRaw() because it not block the all program.
No, don't use ~streamRar(). ~stream() is exactly the same.
The upside of ~stream is that the size of the stream is send first.
In that case the client knows how much data to receive (and doesn't have to wait timeout seconds for the last data).
Your problem with ~streamRar was that it always waits the given timeout to see if the stream is stopped.
~stream() is the better alternative (without the loop around it).
1. Can I use more threads?>I't require 1 core/thread>Can I run a multhreaded app. on a 1 core PC?
If you make sure you don't use global variables you can use multiple threads.
It does not require 1 core/thread. If there are less cores, the threads are divided over the available cores. You then don't have the speed gain of more cores but you do have the flexibility.
2.Can I declare a TTimer in other class? and use it like the visual timer?
That depends how you declare and use it.
You also had a version with a FileSocket. I think that is a better choice than sending the file over the string/message-socket. But ultimately that's your own choice.