Ver Mensaje Individual
  #1  
Antiguo 28-02-2005
zastilla zastilla is offline
Miembro
 
Registrado: sep 2004
Posts: 22
Reputación: 0
zastilla Va por buen camino
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

Última edición por zastilla fecha: 01-03-2005 a las 09:30:02.
Responder Con Cita