如何重用的FtpWebRequest连接FtpWebRequest

2023-09-03 07:32:20 作者:人潮拥挤我该远离

我需要列出成千上万的FTP服务器上的文件,并删除必要的。正如您可以猜到,性能是必不可少的,所以我需要一种方法来重复使用的FTP连接。

I need to list thousands of files on FTP server, and delete the necessary ones. As you can guess, performance is essential, so I need a way to reuse the FTP connection.

没有足够的解释,在MSDN上关于FtpWebRequests的连接使用!它只是说多FtpWebRequests重用现有的连接,如果可能的话。什么是如果可能是什么意思?我想控制何时关闭连接,就这么简单!你知道吗?

There is not enough explanation on MSDN about the connection usage of FtpWebRequests! It only says "Multiple FtpWebRequests reuse existing connections, if possible." What does "if possible" mean? I want to control when to close connection, simple as that! Any idea?

问候

推荐答案

previous连接到服务器的如果可能的话,只要重新用作的KeepAlive 参数来的HttpWebRequest 对象设置为。这种优化的发生多的HttpWebRequest对象的创建和使用的下面。

Previous connections to the server are reused if possible as long as the KeepAlive parameter to the HttpWebRequest object is set to true.This optimization happens underneath the creation and use of multiple HttpWebRequest objects.

对于多线程操作,上有一个特定的主机并发连接数的限制。

With respect to multithreaded operations, there is a limit on the number of concurrent connection to a particular host.

System.Net.ServicePointManager.DefaultConnectionLimit可用于增加并发连接

System.Net.ServicePointManager.DefaultConnectionLimit can used to increase concurrent connections

How改善的FtpWebRequest的性能?
 
精彩推荐
图片推荐