Home Forums .NET libraries Xceed SFTP/FTP for .NET Threading question…

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20650 |

    I’m looking to build a high performance FTP client support up to 20 client connections to one FTP server.

    My question, is with the new 2.0 .NET FTP component, which design would be better use of the component, and more efficient:

    1. Use a single FtpClient or AsyncFtpClient instance, and share that instance among 20 threads, if that’s possible.

    or:

    2. Use 20 different instances of FtpClient or AsyncFtpClient, one for each thread.

    I guess it boils down to if it’s possible to have different threads call upon the same FtpClient or AsyncFtpClient instance, or not?

    Thanks,
    Scott

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by scott_merrill (had 2838 views)

    User (Old forums)
    Member
    Post count: 23064

    I forgot to mention, this will be a console only application, in C#, if that matters.

    Thanks,
    Scott

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by scott_merrill (had 300 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Scott.

    The FTP protocol does not allow a single connected user to perform multiple operations at the same time. Thus you must create an instance of AsyncFtpClient <B>per client connection</B>. The class enforces this FTP protocol limitation by managing a single connection at a time.

    So the answer is #2, but with a remark: The AsyncFtpClient uses the .NET Framework thread pool. Thus, if you create 20 instances of AsyncFtpClient, and only use async method calls (those that start with Begin), you won’t need to create any thread. Simply manage your 20 instances and their pending async calls. I prefer this approach as opposed to creating 20 threads yourself, each one managing an instance of FtpClient or AsyncFtpClient.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Martin (had 3774 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.