CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2001
    Posts
    21

    FtpWebRequest doesn't work in parallel threads

    I work with C# 2.0 VC2008.
    I use a number of Background Workers for open multiply FTP Connections to same FTP Server. The connections are in an Active FTP Mode.
    When I start 2 connections together, the first one is working properly and the second stops after the connection has been established good and waits for Data ( get data only after the first connection closed ).
    When I run two applications with one FTP Session for each, I haven't any problem.


    This is a part of request code :
    Code:
    // sPath =  "ftp://user_name:user_pass@server_address:21//path")
                    FtpWebRequest request = (FtpWebRequest)WebRequest.Create( sPath );  
                    request.UsePassive = false;
                    request.Proxy = null;
                    request.Method = WebRequestMethods.Ftp.GetFileSize;
    
                    this.curFTPState.FileName = Path.Combine(sPathTo, filename);
                    this.curFTPState.FTPMethod = WebRequestMethods.Ftp.GetFileSize;
                    this.curFTPState.Request = request;
    
    
                    // Start the asynchronous request.   
                    IAsyncResult result = (IAsyncResult)request.BeginGetResponse(new AsyncCallback(RespCallback), curFTPState);
    Elina

  2. #2
    Join Date
    May 2007
    Posts
    1,546

    Re: FtpWebRequest doesn't work in parallel threads

    Does the FTP server in question allow multiple connections from the same IP?
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

  3. #3
    Join Date
    May 2001
    Posts
    21

    Re: FtpWebRequest doesn't work in parallel threads

    Yes, actually same application, has run twice with one connection each, is connecting and getting data perfect. On specific server I can open only 2 connections simultaneously, because system limitation.
    Elina

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured