G
Guest
http://msdn2.microsoft.com/en-us/library/21k58ta7.aspx
I'm using that example as my starting point. The timeout it has though is
not bulletproof. It will timeout if it doesn't connect within the timeout
period, but if it connects and the server sends 1 byte and then hangs the
connection open, it will not timeout. I'd like to include another timeout
(let's say 10 seconds) for the read not finishing (or alternatively a timeout
that encompasses the entire process or opening a connection and getting the
response).
Im RespCallback I tried to add another WaitForSingleObject call, but it
didn't seem to help.
// Begin the Reading of the contents of the HTML page and
print it to the console.
IAsyncResult asynchronousInputRead =
responseStream.BeginRead(myRequestState.BufferRead, 0, BUFFER_SIZE, new
AsyncCallback(ReadCallBack), myRequestState);
//ADDED - Added a timeout to confirm that data finishes
reading
ThreadPool.RegisterWaitForSingleObject(asynchronousInputRead.AsyncWaitHandle,
new WaitOrTimerCallback(TimeoutCallback), myHttpWebRequest,
DefaultReadTimeout, true);
Any ideas?
I'm using that example as my starting point. The timeout it has though is
not bulletproof. It will timeout if it doesn't connect within the timeout
period, but if it connects and the server sends 1 byte and then hangs the
connection open, it will not timeout. I'd like to include another timeout
(let's say 10 seconds) for the read not finishing (or alternatively a timeout
that encompasses the entire process or opening a connection and getting the
response).
Im RespCallback I tried to add another WaitForSingleObject call, but it
didn't seem to help.
// Begin the Reading of the contents of the HTML page and
print it to the console.
IAsyncResult asynchronousInputRead =
responseStream.BeginRead(myRequestState.BufferRead, 0, BUFFER_SIZE, new
AsyncCallback(ReadCallBack), myRequestState);
//ADDED - Added a timeout to confirm that data finishes
reading
ThreadPool.RegisterWaitForSingleObject(asynchronousInputRead.AsyncWaitHandle,
new WaitOrTimerCallback(TimeoutCallback), myHttpWebRequest,
DefaultReadTimeout, true);
Any ideas?