Ok. I had a look at the non-modified version.
It seems the RecvStreamRaw() version always waits until the timeout to know that it has the end of the file. It might be better to use RecvStream() (of RecvStreamIndy). With RecvStream(), the size of the file is first transferred and the client knows exactly how much data it should receive. So there is no need for the timeout.
So change Connection.SendStreamRaw to Connection.SendStream
and Connection.RecvStreamRaw to Connection.RecvStream
After that, you don't have a freeze anymore.
Next... if the target file already exists I would add " (1)" to the filename. If that already exists I would add " (2)" etc.
And finally the Unable to create file "".
Somehow... after the filetransfer is done... the GetTimerTimer is triggered again while mode is still fileaccept. That triggers a second TFileStream.Create on an empty filename (which gives the error).
I tried to put a GetTimer.Enabled := false; at the top and a GetTimer.Enabled := true; at the bottom of the timer event but that doesn't work. Although I definitely would add those lines anyway.
For now you could make the line this:
if (mode='fileaccept') and (infile_name <> '') then begin
In that case at least it won't try to create the file
Anyway... The second project with the modified blcksock.pas isn't needed.
I also noticed you had a loop around RecvStreamRaw in that modified project.
That's also not correct because RecvStreamRaw should receive the entire stream and you don't want a loop there.
And the loop on FileSize() isn't even useful because the stream might not have had the time to write it's buffer to the file so the filesize if only definite when .free is called.
Anyway... I would rake your first project and see if you can figure out why the second trigger on the timer is called with infile_name=''.
Edit: I think I found out why the GetTimerTimer gives the unable to create "" error.
You send on the server side a string with Connection.SendString('>StartSendFile'
But DIRECTLY afterwards you send the stream.
It's better to build in a delay before sending so the client has time to set up the receiving end.
(That's why I in the beginning suggested a separate socket for filetransfer might be better)
Sleep(1000);
MainStream := TFileStream.Create(OpenFileDialog.FileName, fmOpenRead);
Connection.SendStream(MainStream);
MainStream.Free;
This should be much better.
O, one final note... During transfer your application does freeze. But that's because the library is 'blocking'. You could hack the synapse code. But if you really want to fix that you'll need threads.