Indy FTP 客户端在尝试开始另一个上传后出现错误?
IdFTP: TIdFTP;
...
procedure TForm1.IdFTPWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
begin
IdFTP.Disconnect;
try
IdFTP.Connect;
IdFTP.ChangeDir( directory );
IdFTP.Put( fileName, ExtractFileName( fileName ) );
except
end;
end;
这是大部分代码。 我希望当第 1 个上传完成后开始另一个上传,但此代码似乎出现错误 10048。
- 将文件和命令序列上传到服务器的正确方法是吗?
- 为什么这个错误 10048 不断上升,以及如何修复它?
IdFTP: TIdFTP;
...
procedure TForm1.IdFTPWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
begin
IdFTP.Disconnect;
try
IdFTP.Connect;
IdFTP.ChangeDir( directory );
IdFTP.Put( fileName, ExtractFileName( fileName ) );
except
end;
end;
This is most of the code.
I wish when the 1 upload complete to start another, but this code seems to rise an error 10048.
- is it correct way to upload sequence of files and commands to the server ?
- why this error 10048 is rising, and how to fix it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要使用
OnWork...
事件来驱动您的业务逻辑!它们仅用于地位。在大多数情况下,Indy 不是事件驱动的,除了一些例外。在这种情况下,
OnWorkEnd
在原始文件数据传输后但在服务器对上传的响应已收到并处理之前触发。上传另一个文件的正确方法是在上次调用Put()
退出后再次调用Put()
,例如:DO NOT use the
OnWork...
events to drive your business logic! They are meant for status only. For the most part, Indy is NOT event driven, minus a few exceptions.In this case,
OnWorkEnd
triggers after the raw file data has been transmitted but BEFORE the server's response to the upload has been received and processed. The correct way to upload another file is to simply callPut()
again after the previous call toPut()
exits, eg:错误 10048 = 套接字已在使用中:信息
您不需要WorkEnd 事件,Put 语句在完成上传文件后返回:
Error 10048 = Socket already in use: info
You don't need the WorkEnd event, Put statement returns when its finished with uploading a file: