我正在尝试使用Indy的IdFTP通过FTP发送和接收一些文件。
function TDatosFTP.TransfiereFTP(Fm: TForm): boolean;
var
TimeoutFTP: integer;
begin
Result := false;
with TIdFTP.Create(Fm) do
try
try
TimeoutFTP := 2000;
Host := Servidor;
Port := 21;
UserName := Usuario;
PassWord := Contra;
Passive := Pasivo;
Connect(true, TimeoutFTP);
if not Connected then
begin
Error := true;
end
else
begin
TransferType := ftASCII;
if Binario then
TransferType := ftBinary;
OnWorkEnd := FinDeTransmision;
if Descargar then
Get(Remoto , Local, True)
else
Put(InterpretarRutaEspecial(Local), Remoto, True);
if Descargar and Borrar then
Delete(Remoto);
Disconnect;
Result := true;
Fm.Hide;
end;
Except on E: Exception do
Mensaje := E.Message;
end;
finally
Free;
end;
if not Result then
ErrorTransmision;
end;
[每当我尝试在主动模式下执行PUT / GET时,都会收到以下错误:EIdProtocolReplyError:'无法建立连接。'在被动模式下可以正常工作。
事实是,我想使用Indy(在项目中的其他地方使用),但是使用OverbyteIcsFtpCli的以前版本的代码在主动和被动模式下都可以正常工作。 这是使用OverbyteIcsFtpCli的代码:
function TDatosFTP.TransfiereFTP(Fm: TForm): boolean;
begin
with TFtpClient.Create(Fm) do
try
HostName := Servidor;
Port := '21';
UserName := Usuario;
PassWord := Contra;
HostDirName := '';
HostFileName := Origen;
LocalFileName := InterpretarRutaEspecial(Destino);
Binary := Binario;
Passive := Pasivo;
OnRequestDone := FinDeTransmision;
if Descargar then
Result := Receive
else
Result := Transmit;
OnRequestDone := nil;
if Descargar and Borrar then
Delete;
Result := Result and not Error;
Fm.Hide;
if not Result then
ErrorTransmision;
finally
Free;
end;
end;
因此,我使用Wireshark进行了深入研究,发现Indy的FTP无法应答来自服务器的某些消息。
这是具有OverBytes的FTP的文件传输握手:
我以黄色突出显示了服务器和客户端之间发送的两个开始数据传输的数据包。现在,让我们看看Indy的FTP会发生什么:
服务器正在发送数据包以开始文件传输,但IdFTP没有应答。
我见过this question,但是这两个测试是在同一台计算机,相同的网络连接,相同的防火墙等上运行的。也是this one,但我希望FTP在主动和被动模式下都能工作[[both
模式。发生了什么事?
我正在尝试使用Indy的IdFTP通过FTP发送和接收一些文件。函数TDatosFTP.TransfiereFTP(Fm:TForm):布尔值; var TimeoutFTP:整数; begin结果:= false;使用TIdFTP.Create(...