Proyecto

General

Perfil

Descargar (3,11 KB) Estadísticas
| Rama: | Revisión:
{
Adtos 1.0 Software de gestión de Aulas Tecnológicas
Copyright (C) 2008-2009, Consejería de Educación,Junta de Extremadura
Programación: Manuel Narváez Martínez <mnarvaez007@gmail.com>
Diseño gráfico: Ana María Zamora Moreno
Desarrollado con Lazarus 0.9.26

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit clenviararchivo;

{$mode objfpc}{$H+}

interface

uses
globales,Classes,IdSSLOpenSSL, SysUtils,IdTCPClient;

type
ThrEnviar = class(TThread)
private
{ Private declarations }
farchivo:string;
fhost,fcomando:string;
fpuerto:integer;
fIdSSLIOHandlerSocketOpenSSL: TIdSSLIOHandlerSocketOpenSSL;
fcliente:TIdTcpClient;
protected
procedure Execute; override;
public
constructor Create(host,comando,archivo:string);
end;

implementation

constructor ThrEnviar.Create(host,comando,archivo:string);
begin
inherited Create(true);
fpuerto:=PUERTO_USUARIO;
fhost:=host;
fcomando:=comando;
FreeOnTerminate:=True;
farchivo:=archivo;
end;

procedure ThrEnviar.Execute;
var
lstream:TFileStream;
begin
try
//writeln('ThrEnviar fcomando '+ fcomando);
//writeln('ThrEnviar farchivo '+ farchivo);
fIdSSLIOHandlerSocketOpenSSL:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
fIdSSLIOHandlerSocketOpenSSL.Port:= fpuerto;
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode:=sslmClient;
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.Method:=sslvSSLv3;
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.SSLVersions:=[sslvSSLv3];
fcliente:=TidTcpClient.create(nil);
fcliente.IOHandler:=fIdSSLIOHandlerSocketOpenSSL;
lstream:= TFileStream.Create(farchivo,fmOpenRead + fmShareDenyNone);
fcliente.Host:=fhost;
fcliente.port:=fpuerto;
fcliente.connect;
try
fcliente.getResponse(200);
fcliente.sendcmd(fcomando,252);
fcliente.IOHandler.writebufferopen;
fcliente.IOHandler.Write(lstream,0,true);
fcliente.IOHandler.WriteBufferclose;
finally
begin
fcliente.Disconnect;
fcliente.free;
fIdSSLIOHandlerSocketOpenSSL.Free;
lstream.free;
end;
end;
except
writeln('Error al enviar el archivo');
end;
end;

end.

(17-17/57)