I am looking for how to control the ftp operations so that they do not take
longer than certain time.
I have the option of doing them on a separate thread but, is there a way of
doing with the CFtpConnection object itself?
Thanks.
You can get some granularity in the transfer if, instead of PutFile(), you
write the file in chunks using something like the following pseudocode:
CFtpConnection::OpenFile(, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, )
while (more bytes to write && nottimedout)
{
CInternetFile::Write()
}
CInternetConnection::Close
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
>
> Thanks.
> CFtpConnection::OpenFile(, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, )
> while (more bytes to write && nottimedout)
> {
> CInternetFile::Write()
> }
> CInternetConnection::Close
>
But, I would have no control over the max time the CInternetFile::Write call
may take. What if I want a guarantee that the Write call will not take more
than certain time to complete?
Thanks
AFAIK, all you can do is monitor from another thread. You'd have to do that
even using FtpPutFile asynchronously.
From various places on the Internet, I found that one can use the
INTERNET_OPTION_SEND_TIMEOUT option to set the timeout on ftp puts:
// //////////////////////////////////////////
CInternetSession session;
session.SetOption(INTERNET_OPTION_SEND_TIMEOUT, 10000); // 10 secs.
CFtpConnection* pftp = session.GetFtpConnection(...);
if ( !pftp->PutFile(...) ) { // how to check what the reason for the failure
was?
...
}
// //////////////////////////////////////////
Two questions:
1. Why wouldn't this work? It does not require a thread to monitor for time
outs (at least in the client code)
2. How to find out what the reason for the failure was inside the if
statement above?
Thank you very much:
Abel Quiros
That should work fine I would think. Thanks for pointing that out to me.
> 2. How to find out what the reason for the failure was inside the if
> statement above?
If (Ftp)PutFile() returns an error, GetLastError() would probably return
ERROR_INTERNET_TIMEOUT.
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
>
> >> AFAIK, all you can do is monitor from another thread. You'd have to do
> >> that
> >> even using FtpPutFile asynchronously.
Sorry for the dumb question but, what is AFAIK?
> > Two questions:
> > 1. Why wouldn't this work? It does not require a thread to monitor for
> > time
> > outs (at least in the client code)
>
>
> That should work fine I would think. Thanks for pointing that out to me.
After some searching on the net I found that apparently, the option
INTERNET_OPTION_SEND_TIMEOUT does not work. Please, see
http://support.microsoft.com/kb/176420/en-us
Thanks.
Victor
"beluchin" <belu...@discussions.microsoft.com> wrote in message
news:73089033-777F-4010...@microsoft.com...
>
>
>> >> c, all you can do is monitor from another thread. You'd have to do