错误10038“套接字在非套接字上操作”后未定义的TIdFTP状态 [英] Undefined TIdFTP status after error 10038 “Socket operation on non-socket”

查看:1003
本文介绍了错误10038“套接字在非套接字上操作”后未定义的TIdFTP状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用TIdFTP控件连接到FTP服务器。看来,



如何重置FTP控件的状态(我该如何断开连接)?

解决方案


我使用TIdFTP控件连接到FTP服务器。看起来,我的FTP连接在60秒钟不活动后被某些东西(ftp服务器/防火墙?)终止

TIdFTP 具有 NATKeepAlive 属性,以避免通过FTP不知道的路由器/防火墙连接时发生的确切问题。在传输过程中,控制连接暂时启用了TCP Keepalive,因此它不会过早关闭。


但是,FTP.Connected显示True 。

这意味着 IOHandler.InputBuffer 可能有未读取的数据。 Connected()被设计为返回True,如果即使套接字已关闭,读操作仍然可以被满足。


尝试使用FTP.Disconnect为我提供了一个'正常关闭的连接'错误


默认情况下, Disconnect()在关闭套接字之前向服务器发送一个 QUIT 命令。



Disconnect()有一个可选的 ANotifyPeer 参数,您可以将其设置为False以跳过 QUIT 命令。



你也应该在意外的断开连接之后 Clear() IOHandler.InputBuffer 清除所有未读数据。


唯一的解决方法是结束程序并重新开始。

这永远不是解决方案。更糟糕的情况是,您可以简单地销毁 TIdFTP 对象并创建一个新对象。但如果你按照上面的步骤,你甚至不需要诉诸于此。


I use a TIdFTP control to connect to an FTP server. It seems that my FTP connection is terminated by something (ftp server/firewall?) after 60 seconds of inactivity. Once the connection was terminated I cannot use the FTP control (TIdFTP) anymore because its status is undefined. For example, every time I try to REconnect I get the same (10038) error. However, FTP.Connected shows True. Trying FTP.Disconnect gives me a 'connection closed gracefully' error and the control remains connected. The only solution is to end the program and start it again.

The NAT Keep Alive is already set to 15000.

How to reset the status of the FTP control (how do I disconnect)?

解决方案

I use a TIdFTP control to connect to an FTP server. It seems that my FTP connection is terminated by something (ftp server/firewall?) after 60 seconds of inactivity

TIdFTP has a NATKeepAlive property to avoid that exact issue from happening when connected through an FTP-unaware router/firewall. During a transfer, TCP keepalives are temporarily enabled on the control connection so it does not get closed prematurely.

However, FTP.Connected shows True.

That means the IOHandler.InputBuffer likely has unread data in it. Connected() is designed to return True if read operations can still be satisfied even if the socket has been closed.

Trying FTP.Disconnect gives me a 'connection closed gracefully' error

By default, Disconnect() sends a QUIT command to the server before closing the socket. Since the connection is already gone, that send fails.

Disconnect() has an optional ANotifyPeer parameter that you can set to False to skip the QUIT command.

You should also Clear() the IOHandler.InputBuffer after an unexpected disconnect to clear out any unread data.

The only solution is to end the program and start it again.

That is never the solution. Worse case, you could simply destroy the TIdFTP object and create a new one. But if you follow the steps above, you should not need to resort to even that.

这篇关于错误10038“套接字在非套接字上操作”后未定义的TIdFTP状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆