I am trying to do a "long polling" with an HttpWebRequest object.
In my C # application, I am making an HTTP GET request using HttpWebRequest. And then, then, I'm waiting for an answer with beginGetResponse (). I use ThreadPool.RegisterWaitForSingleObject to wait for a response or timeout (after 1 minute).
I set the target web server for a long time to respond. Thus, I have time to disconnect the network cable.
After sending the request, I pull out the network cable.
Is there any way to get an exception when this happens? So I do not need to wait for a timeout?
Instead of an exception, a timeout (from RegisterWaitForSingleObject) occurs after a timeout of 1 minute has elapsed.
Is there a way to determine if the network connection is down? Currently, this situation is indistinguishable from the case when the web server takes more than 1 minute to respond.
source share