Trying to develop an FTP app using WinInet commands.
My session, callback declaration & connection:
//Create the Internet session, using global handles so they can be
//seen by the callback
g_hSession = InternetOpen("TestWinInet",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL,
INTERNET_FLAG_ASYNC);
if (g_hSession)
{
INTERNET_STATUS_CALLBACK dwStatusCallback;
dwStatusCallback = InternetSetStatusCallback(g_hSession,
MyStatusCallback);
if (INTERNET_INVALID_STATUS_CALLBACK == dwStatusCallback)
{
AfxMessageBox("Error status callback");
}
}
//make the connection
g_hConnection = InternetConnect(g_hSession, sServer,
INTERNET_DEFAULT_FTP_PORT,
sDestUser,sDestPwd,
INTERNET_SERVICE_FTP,
INTERNET_FLAG_PASSIVE ,
CONNECT_CONTEXT);
If I do not use 'INTERNET_FLAG_ASYNC' , wait for a valid 'g_hConnection,
and then do a 'FtpPutFile(....)', it seems to work.
But, if I do use 'INTERNET_FLAG_ASYNC', and wait for the callback,
case INTERNET_STATUS_REQUEST_COMPLETE:
{
//use function to put file
}
then try to do a 'FtpPutFile(...)' I get an error code of "997",
' overlapped I/O operation in progress'?? What overlapped?
The 'g_hConnection' is valid, and I don't know where to go from here??
I would like to do FTP asynchronously, but I sure am having trouble with
the
callback. Even when I use FtpCommand with 'NLST', the command is xmitted
but it just seems to wait for a data port to be opened?
So, if anybody could tell me or show me how to properly use the callback,
I would appreciate it?
TIA,
Ray K.
This behaviour is descibed here:
http://msdn.microsoft.com/library/en-us/wininet/wininet/common_functions.asp
There are various other documents on MSDN that will help you:
http://msdn.microsoft.com/library/en-us/wininet/wininet/asynchronous_operation.asp
http://msdn.microsoft.com/library/en-us/wininet/wininet/calling_wininet_functions_asynchronously.asp
Paul
"raykos" <ray...@discussions.microsoft.com> wrote in message
news:F3AF23E5-084D-476A...@microsoft.com...
Thanks for responding. It looks like the result code from 'FtpPutFile'
is indeed
ERROR_IO_PENDING. I haven't done anything with it, yet, but what threw a
curve
at me was when I did a GetLastError, the return value was '997'. I'm using
MFC 6.0, so I went up to the menu bar->tools->error lookup, and put in
'997'. It comes
back with 'Overlapped I/O in progress', which I had no idea what that was.
However, if I go into 'winerror.h' and look up 'ERROR_IO_PENDING' it, of
course, has the value of 997L. Sometimes, Microsoft, can be very
frustrating!
But, now I can move on to the next problem....
Again thanks,
Ray K.