Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CFtpConnection::PutFile timeout

290 views
Skip to first unread message

beluchin

unread,
Jul 17, 2008, 4:20:06 PM7/17/08
to
how can I make CFtpConnection::PutFile to terminate after some time regarding
of the status of the transfer?

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.

Mark Salsbery [MVP]

unread,
Jul 17, 2008, 4:53:34 PM7/17/08
to
"beluchin" <belu...@discussions.microsoft.com> wrote in message
news:80CB01C9-D253-4DA8...@microsoft.com...


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.

beluchin

unread,
Jul 18, 2008, 10:25:01 AM7/18/08
to

"Mark Salsbery [MVP]" wrote:

> 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

Mark Salsbery [MVP]

unread,
Jul 18, 2008, 12:28:45 PM7/18/08
to
"beluchin" <belu...@discussions.microsoft.com> wrote in message
news:E3E05E71-4657-4C07...@microsoft.com...


AFAIK, all you can do is monitor from another thread. You'd have to do that
even using FtpPutFile asynchronously.

beluchin

unread,
Jul 21, 2008, 9:01:02 AM7/21/08
to

> 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

Mark Salsbery [MVP]

unread,
Jul 21, 2008, 2:20:31 PM7/21/08
to

"beluchin" <belu...@discussions.microsoft.com> wrote in message
news:1B65B935-9DCB-4C5A...@microsoft.com...

>
>> 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)


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++


>

beluchin

unread,
Jul 21, 2008, 2:41:02 PM7/21/08
to

> >> 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

unread,
Jul 21, 2008, 3:08:04 PM7/21/08
to
AFAIK = As Far As I Know.
See http://www.internetslang.com/AFAIK.asp

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

0 new messages