Solved

Errors using CInternetFile for ftp transfer

Posted on 2004-08-13
4
511 Views
Last Modified: 2013-11-20
I have an application that connects to an ftp server and downloads *.zip files to the client.  I'm having some problems with users who use XP Home and have some sort of home network setup that shares a broadband connection.

I'm using CInternetSession to connect.  I use a direct connection for aol/compuserve users:
aol/compuserve users:  pDlg->m_dlgAutoUpdate.isess = new CInternetSession(NULL,1,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);

OR

regular users: pDlg->m_dlgAutoUpdate.isess = new CInternetSession



And CInternetFile to transfer the file:

    CInternetFile* pRemoteFile = pDlg->m_dlgAutoUpdate.pConn->OpenFile(tis->strFilename,
        GENERIC_READ, INTERNET_FLAG_NO_CACHE_WRITE | FTP_TRANSFER_TYPE_BINARY, tis->dwID);

    while(TRUE) {
       UINT nActual= pRemoteFile->Read(inBuf, 4096);
       fLocalFile.Write(inBuf, nActual);
       pDlg->m_dlgAutoUpdate.PostMessage(WM_USER_THREAD_UPDATE_DOWNPROGRESS,lCurProgress,0);
                  
       strMsg.Format("%d of %d KB", (lCurProgress / 1028), (tis->nFilesize / 1028));
       pDlg->m_dlgAutoUpdate.m_mKB.SetWindowText(strMsg);
               
       if(nActual != 4096)            // reached end of file!
       {
            pDlg->m_dlgAutoUpdate.PostMessage(WM_USER_THREAD_UPDATE_DOWNPROGRESS,tis->nFilesize,1);
            break;
       }
     }


On the problematic machines, the app connects OK to the server, but when the file transfer begins, they get a number of errors which stop the process:
- error 800: blah blah blah... consider using PASV
- error 426 ...Failure writing network stream...
- error 150 ...opening in binary mode...

No files are downloaded.  Anyone with suggestions?

Thanks,

MT
0
Comment
Question by:supertedusa
  • 2
4 Comments
 
LVL 6

Expert Comment

by:Amritpal Singh
ID: 11799077
i'm not sure
but following link may be of help
http://www.funducode.com/freevc/internet/internet5/internet5.htm
BOL
0
 

Author Comment

by:supertedusa
ID: 11809954
Thanks,  but that article only covers the basics and doesn't tell me anything new.

MT
0
 
LVL 2

Accepted Solution

by:
MikeAThon earned 500 total points
ID: 11835030
This might be a firewall issue.  PASV mode is a "passive" mode in the FTP protocol that is designed to circumvent difficulties caused by firewalls.  The PASV command requests the server-DTP to "listen" on a data port (which is not its default data port) and to wait for a connection, rather than initiate one upon receipt of a transfer command.  See RFC-959, "File Transfer Protocol" at http://www.ietf.org/rfc/rfc0959.txt

If it indeed is a firewall issue, I don't know how to solve it.  Sorry.  Maybe you can set your FTP connection to passive mode in CInternetSession::GetFtpConnection, by setting the bPassive parameter to TRUE

Regards,
Mike
0
 

Author Comment

by:supertedusa
ID: 11835805
I'll try the passive parameter and let you know if that works.  Thanks,

MT
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 125
deburging in oracle form 12 99
only14 challenge 19 76
Capture logon name 13 73
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question