Link to home
Start Free TrialLog in
Avatar of Sassa
Sassa

asked on

error 12003 while communicating with an ftp server

I am writing an ftp client using MFC. The particular server that my client is communicating with is A Bulletproof ftp server. I connect to the server by creating an CInternetSession object and then I call its member function GetFtpConnection. Randomly, the functions SetCurrentDirectory, OpenFile etc. does not succeed and return error code 12003. I read about that error in MSDN and found that the error 12003 could occur when the server is not a Microsoft server, since it sends back status messages that the MFC functions do not know how to handle. A solution is suggested: Set the flag INTERNET_FLAG_PASSIVE to FALSE and the server won't send any status messages. So my code looks like this now:

CInternetSession* m_pInternetSession = NULL;
try
{
  m_pInternetSession = new CInternetSession(m_csAppname, 1, INTERNET_OPEN_TYPE_DIRECT, 0, 0,
                             INTERNET_FLAG_DONT_CACHE);
  //m_pInternetSession->SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 500);
  //m_pInternetSession->SetOption(INTERNET_OPTION_CONNECT_RETRIES, 3);
         
  m_pFtpConnection = m_pInternetSession->GetFtpConnection(m_pcsServername, m_pcsUsername,
                                                          m_pcsPassword, INTERNET_DEFAULT_FTP_PORT, FALSE);

}
catch (CInternetException* pEx)
{
...    
}
Before I read about the INTERNET_FLAG_PASSIVE, the code was identical except from the 5:th argument in GetFtpConnection. I have now added FALSE. Before I didn't even give a 5:th argument.
Still the server keeps sending the client messages that generates the error 12003, ie nothing changed when I set this flag.

Does anyone know how to handle this????
Avatar of AlexFM
AlexFM

bPassive

Specifies passive or active mode for this FTP session. If set to TRUE, it sets the Win32 API dwFlag to INTERNET_FLAG_PASSIVE.

Maybe you need to set TRUE and not FALSE?
Avatar of Sassa

ASKER

I am quite sure that it should be false. Quotation from MSDN:

"The above behavior may be avoided by not using the INTERNET_FLAG_PASSIVE flag in the InternetConnect or InternetOpenUrl API. When this flag is not used WinInet uses active semantics for the FTP connection, which avoids the return of the status code, which causes the parsing problem."


ASKER CERTIFIED SOLUTION
Avatar of ee_ai_construct
ee_ai_construct
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial