Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   r que r con cliente/servidor y streams (https://www.clubdelphi.com/foros/showthread.php?t=18963)

zastilla 28-02-2005 18:48:58

r que r con cliente/servidor y streams
 
bueno ya he solucionado el tema de que al perderse o finalizar la conexion el archivo que se envia por el stream se quede a cero.
uso las indy 9 del delphi7
cliente:

Código:


procedure TForm1.Button6Click(Sender: TObject);
 
var
 
stream: TStream;
 
begin
 
IdTCPClient1.WriteLn('getfile ' + HttpEncode (edit2.Text));
 
Stream := TfileStream.Create('c:\pepeddd.zip',fmCreate or fmOpenWrite );
 
try
 
stream.Position := strtoint(label1.Caption);
 
IdTCPClient1.ReadStream(stream);
finally
stream.Free;


servidor:

Código:


procedure TForm1.IdTCPServer1TIdCommandHandler2Command(
 
ASender: TIdCommand);
 
var
 
filename: string;
 
fstream: TFileStream;
 
begin
 
if Assigned (ASender.Params) then
 
filename := HttpDecode(ASender.Params [0]);
 
 
 
if not FileExists (filename) then
 
begin
 
ASender.Response.Text := 'File not found';
 
memo1.Lines.Add ('File not found: ' + filename);
 
raise EIdTCPServerError.Create ('File not found: ' + filename);
 
end
 
else
 
begin
 
fstream := TFileStream.Create (filename, fmOpenRead);
 
try
 
ASender.Thread.Connection.WriteStream(fstream, True, True);
 
label3.Caption:=inttostr(asender.Thread.Connection.SendBufferSize);
 
memo1.Lines.Add ('File returned: ' + filename +
 
' (' + IntToStr (fStream.Size) + ')');
 
finally
 
fstream.Free;
 
end;
 
end;
 
end;
 

los problemas vienen que el cliente se queda pillado hasta que termina el envio, da igual que ponga un anifreeze.
para hacer las prueba desconecto el servidor y compruebo que el archivo no se queda a cero.

alguien sabe como evitar que el cliente se quede colgado?

gracias

srneo 05-10-2006 21:56:40

Podria ser...
 
Si incluis un time en la coneccion que espere determinado tiempo, no es la mejor solucion pero podria funcionar depende de lo que necesites


La franja horaria es GMT +2. Ahora son las 06:27:13.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi