title: Test for open port before attempting HttpClient connection
body: <p>The various methods of the <a href="http://msdn.microsoft.com/en-us/library/hh193681.aspx" rel="nofollow">HttpClient</a> class (GetAsync etc.) take a Uri object or string and attempt to open a connection to the specified location. However it's very likely in my case that the remote host is not listening (the port is closed and will be actively refused; it's inside our LAN).</p>
  
  <p>I'd rather not rely on catching an exception to handle this scenario, especially since these methods throw an <a href="http://msdn.microsoft.com/en-us/library/system.aggregateexception.aspx" rel="nofollow">AggregateException</a> which I'd then have to sift through.</p>
  
  <p>Is there a better way to detect this scenario while still getting the benefits of the HttpClient class (the remote host is a WebApi service)? Should I check to see if the port is listening beforehand using something like TcpClient? Of course that involves a race condition between the calls. I'm hoping that the constructor overload that takes an HttpMessageHandler will help, but nothing in <a href="http://msdn.microsoft.com/en-us/library/system.net.http.webrequesthandler.aspx" rel="nofollow">WebRequestHandler</a> is jumping out at me either...</p>