title: HttpWebRequest & Long Polling: how can I tell if a Long Polling connection has been established?
body: <p>I need to make a long polling connection between my application and the server.  I am using HttpWebRequest class and it works:</p>
  
  <pre><code>    for (; ; )
      {
          System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
  
          request.Timeout = 100000;
          request.Method = "GET";
          request.KeepAlive = true;
          request.Credentials = System.Net.CredentialCache.DefaultCredentials;
  
          var response = request.GetResponse();
          :
          : (wait for response...)
      }
  </code></pre>
  
  <p>I need to know whether the server is online or not.  If it is offline, the application needs to immediately notify the user.  However, if the server is offline, the GetResponse() won't return any error until it has reached the timeout.</p>
  
  <p>I can't reduce the timeout to say 0.1s neither because the application is supposed to sit and wait for the reply from the server.</p>
  
  <p>My question is if there is any way for me to tell immediately when a connection with the server has been successfully established (without disconnecting from the server of course)?</p>
  
  <p>Please help.  Thank you.</p>