Bryan Wilcox
2004-09-01 16:13:14 UTC
Hello,
We are using MFC wrapped WinInet functions on CInternetSession,
CHttpConnection, and CHttpFile to add the ability to communicate to a
server on the Internet from within our C++ PC applications. We have
run into the problem that I have seen described where CHttpFile's
SendRequest will block for a very long time if the server is
non-responsive. I found this article in MSDN:
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q224/3/18.ASP&NoWebContent=1
describing how to get around this problem by putting the blocking
calls into a thread and add a "time-out" there. The issue that I have
run into is that the article says you must "call InternetCloseHandle
to release the blocking WinInet function" which in MFC terms means
that you must call close on the CInternetSession object (at least to
my limited understanding of all this). This will allow the
SendRequest to return and allow the worker thread to be able to
terminate. However, the creates another issue. Our application has
the capability to connect through a proxy server. We share the same
CInternetSession object && CHttpConnection object across multiple
calls from within the same application. We get the user's Proxy
username / password once using the ErrorDlg on CHttpFile. This seems
to somehow get automagically cached in WinInet (I am assuming in the
CInternetSession object) so that future SendRequests don't require a
UI to get the user's password. Hence the problem. If I have to
"Close" the Session to allow my worker thread to be able to timed out
or be aborted, that means if we do a subsequent call, we would have to
open a new CInternetSession. This seems like it would require a user
to reauthenticate themselves to the proxy server, which to me seems
annoying.
The high level goals of what I am trying to accomplish are to allow
the user to be able to cancel a communication to the Internet if the
server is non-responsive, but be able to make additional
communications with the Internet from within the same application
while only having to authenticate with the proxy server once. I have
similar concerns about people who use dial-up, does closing this
CInternetSession object kill the dial-up connection. We,
unfortunately, don't have a simple way to test dial-up connections in
our office.
Am I missing something here? Any help would be appreciated.
Thanks,
Bryan
We are using MFC wrapped WinInet functions on CInternetSession,
CHttpConnection, and CHttpFile to add the ability to communicate to a
server on the Internet from within our C++ PC applications. We have
run into the problem that I have seen described where CHttpFile's
SendRequest will block for a very long time if the server is
non-responsive. I found this article in MSDN:
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q224/3/18.ASP&NoWebContent=1
describing how to get around this problem by putting the blocking
calls into a thread and add a "time-out" there. The issue that I have
run into is that the article says you must "call InternetCloseHandle
to release the blocking WinInet function" which in MFC terms means
that you must call close on the CInternetSession object (at least to
my limited understanding of all this). This will allow the
SendRequest to return and allow the worker thread to be able to
terminate. However, the creates another issue. Our application has
the capability to connect through a proxy server. We share the same
CInternetSession object && CHttpConnection object across multiple
calls from within the same application. We get the user's Proxy
username / password once using the ErrorDlg on CHttpFile. This seems
to somehow get automagically cached in WinInet (I am assuming in the
CInternetSession object) so that future SendRequests don't require a
UI to get the user's password. Hence the problem. If I have to
"Close" the Session to allow my worker thread to be able to timed out
or be aborted, that means if we do a subsequent call, we would have to
open a new CInternetSession. This seems like it would require a user
to reauthenticate themselves to the proxy server, which to me seems
annoying.
The high level goals of what I am trying to accomplish are to allow
the user to be able to cancel a communication to the Internet if the
server is non-responsive, but be able to make additional
communications with the Internet from within the same application
while only having to authenticate with the proxy server once. I have
similar concerns about people who use dial-up, does closing this
CInternetSession object kill the dial-up connection. We,
unfortunately, don't have a simple way to test dial-up connections in
our office.
Am I missing something here? Any help would be appreciated.
Thanks,
Bryan