WinINet FTP Bug with passive connection
- From: BHunsaker <BHunsaker@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 9 May 2008 11:29:02 -0700
Somewhat randomly, I am receving error 12002 (ERROR_INTERNET_TIMEOUT) from a
call to the WinINet InternetConnect function while trying to set up an FTP
session with a remote server.
In looking at a Ethereal/Wireshark trace of the network packets, my client
sends out the PASV request, the server responds with the 227 "entering
passive mode" packet, but my client never even trys to open the port
specified in the 227 message.
It isn't clear whether InternetConnect is responsible for opening the
specified port or if that would be the responsibility of the call to
FtpPutFile which follows. But no matter, as the InternetConnect returns an
error which, in my opinion, means something is wrong and I should close down
the connection.
The software firewall is disabled. I don't see how it could be a firewall
on the network causing the problem as the Wireshark trace clearly shows the
FTP server is folowing the protocol spec and it is my failure to open the
specified port.
Any thoughts?
Windows Server 2003 Standard Edition SP2
Below is the C++ code:
----------------------------
::HINTERNET iHandle = ::InternetOpen(
"TEST",
INTERNET_OPEN_TYPE_DIRECT,
NULL,
NULL,
0 );
if ( NULL == iHandle )
{
LOG_ERROR( std::string( "Unable to access internet: " )
+ formatSystemError( ::GetLastError() ) );
}
else
{
::HINTERNET ftpSession = ::InternetConnect(
iHandle,
m_ipAddress.c_str(),
INTERNET_DEFAULT_FTP_PORT,
m_username.c_str(),
m_password.c_str(),
INTERNET_SERVICE_FTP,
INTERNET_FLAG_PASSIVE,
0 );
if ( NULL == ftpSession )
{
LOG_ERROR( formatInternetError(
"Unable to connect to FTP server (" + m_ipAddress + "):",
::GetLastError() ) );
}
else
{
std::string remoteFileName( fileName.substr( fileName.find_last_of( '\\'
) + 1 ) );
if ( !::FtpSetCurrentDirectory( ftpSession, m_targetDirectory.c_str() ) )
{
LOG_ERROR( formatInternetError(
"Unable to set default directory on remote FTP server to " +
m_targetDirectory + ":",
::GetLastError() ) );
}
else if( !::FtpPutFile(
ftpSession,
fileName.c_str(),
remoteFileName.c_str(),
INTERNET_FLAG_TRANSFER_ASCII,
0 ) )
{
LOG_ERROR( formatInternetError(
"Unable to send " + fileName + " to " + remoteFileName + " on remote
FTP server:",
::GetLastError() ) );
}
::InternetCloseHandle( ftpSession );
}
::InternetCloseHandle( iHandle );
}
.
- Follow-Ups:
- Re: WinINet FTP Bug with passive connection
- From: Volodymyr M. Shcherbyna
- Re: WinINet FTP Bug with passive connection
- Prev by Date: Re: Problem with ATL service and NetMon component.
- Next by Date: IP Address Control Box on Win 2000?
- Previous by thread: Problem with ATL service and NetMon component.
- Next by thread: Re: WinINet FTP Bug with passive connection
- Index(es):
Relevant Pages
|
|