How to Reuse FtpWebRequest Connection

两盒软妹~` 提交于 2019-12-19 01:46:33

问题


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.

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?

Regards


回答1:


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 can used to increase concurrent connections

  • How to improve the Performance of FtpWebRequest?


来源:https://stackoverflow.com/questions/7132246/how-to-reuse-ftpwebrequest-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!