【发布时间】:2016-12-17 20:51:51
【问题描述】:
我想从 FTP 服务器下载一些大文件 (GB)。 第一个文件的下载始终有效。然后在尝试获取第二个文件时,我得到:
“套接字错误#10038。非套接字上的套接字操作。”
错误出现在“获取”上。在“获取”之后,我看到了这些消息(通过 FTP 状态事件):
Starting FTP transfer
Disconnecting.
Disconnected.
代码是这样的:
{pseudo-code}
for 1 to AllFiles do
begin
if Connect2FTP then
begin
FTP.Get(Name, GzFile, TRUE, FALSE); <--- Socket operation on non-socket" error (I also get EIdConnClosedGracefully 'Connection Closed Gracefully' in IDE, F9 will resume execution without problems, but this is OK)
Unpack(GzFile); <--- this takes more than 60 seconds
end;
end;
if FTP.Connected
then FTP.Disconnect;
--
function Connect2FTP(FTP: TIdFTP; RemoteFolder: string; Log: TRichLog): Boolean;
begin
Result:= FTP.Connected;
if NOT Result then
begin { We are already connected }
FTP.Host := MyFTP;
FTP.Username:= usr;
FTP.Password:= psw;
TRY
FTP.Connect;
EXCEPT
on E: Exception DO
Result:= FTP.Connected;
if Result then FTP.ChangeDir(RemoteFolder);
end;
end;
完整代码在这里:http://pastebin.com/RScj86R8 (PAS) 或这里 https://ufile.io/26b54 (ZIP)
我认为在调用“Unpack”后会出现问题,这需要几分钟时间。
更新:确认:调用“解包”后出现问题。我删除了电话,一切都很好。在下载之间暂停(睡眠或断点)程序一段时间(我认为超过 60 秒)会产生同样的问题。
【问题讨论】:
-
这值得商榷。该代码无法编译,您已经完成了其中的重要部分。我建议你花更多的时间在这个问题上。显然你有一个问题,但如果你在你的问题上投入更多的精力,你会得到更好的帮助。在这里问了 290 个问题后,我很难相信您不知道该怎么做,为什么需要提供minimal reproducible example。啊,现在我看到你还在添加更多,即使在上面的评论之后。无论如何,10038 表示你关闭了套接字,然后再次尝试使用它。
-
现在你知道去哪里看
-
既然你是唯一一个有repro和实际代码的人,我想你需要调试它。
-
好吧,我猜那一切都很好,正在使用的套接字也很好,抛出10038时系统错误。
标签: delphi ftp indy delphi-xe7 indy10