Лучше по UDP протоколу передавать файлы. Вот код. Думаю поможет.
Code
var
FStream : TFileStream;
begin
FStream:=TFileStream.Create('путь к передаваемому файлу', fmOpenRead);
SendProcedure(FStream, UDPClient, StatusLabel, ProgressBar);
FStream.Free;
end;
procedure SendProcedure(FStream: TFileStream; UDPClient: TIdUDPServer;);
var
i,j,count: integer;
buf : array[1..40000] of Char;
begin
i := round(FStream.Size/40000);
if (i*40000<FStream.Size) then i:=i+1;
UDPClient.Send('localhost',9989,'count_buf:'+IntToStr(i)+'#');
Application.ProcessMessages;
for j:=1 to i do
begin
if i=j then
count:=FStream.Read(buf,FStream.Size-((i-1)*40000))
else
count:=FStream.Read(buf,length(buf));
UDPClient.SendBuffer('localhost', 9989, buf, count);
while get_accept=false do Application.ProcessMessages;
get_accept := false;
end;
end;
procedure TMainForm.UDPServerUDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
str_buf : array[1..20] of Char;
begin
// åñëè ïåðâûé ðàç, òî ñ÷èòûâàåì äàííûå îá êîëëè÷åñòâå ïàêåòîâ, êîòîðûå íóæíî áóäåò ïðèíÿòü
// ñîçäàåì ïîòîê äëÿ ôàéëà
if first_=true then
begin
AData.Read(str_buf,length(str_buf));
if copy(str_buf,1,10)='count_buf:' then
get_buffers:=StrToInt(copy(str_buf,11,pos('#',str_buf)-11));
if SaveDialog.Execute then
begin
first_:=false;
ServerStream:=TFileStream.Create(SaveDialog.FileName,fmCreate);
end;
end else
begin
get_buf_num:=get_buf_num+1;
ServerStream.Position:=ServerStream.Size;
ServerStream.CopyFrom(AData,AData.Size);
UDPServer.Send('localhost',1152,'accept');
if get_buffers=get_buf_num then
begin
ShowMessage('Âñå, ïðèíÿòî!');
ServerStream.Free;
end;
end;
end;
procedure TMainForm.UDPClientUDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
begin
get_accept:=true;
end;