FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
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); 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; 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. |
#2
|
|||
|
|||
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
|
|
|
|