title: Quickest way to check if WCF service is running
body: <p>I have a WCF service running locally. The service has a default port that it runs on, but if that port is already in use then I assign the port dynamically.</p>
  
  <p>I added this in the host to make it discoverable:</p>
  
  <pre><code>serviceHost.Description.Behaviors.Add(new ServiceDiscoveryBehavior());
  serviceHost.AddServiceEndpoint(new UdpDiscoveryEndpoint());
  </code></pre>
  
  <p>Now my client needs to connect to this host. In the client I want to have it first try the default port, and if it can't connect to the service on the default port, then it will do the discovery.</p>
  
  <p>I've found that the discovery takes about 20-30 seconds, so I would prefer to avoid always doing it, only when it can't find the host on the default port.</p>
  
  <p>So my question is: what is the quickest way to determine if my host is on the default port? </p>
  
  <p>I was thinking about doing something like setting the open timeout on the client to 10 seconds, and then doing a try/catch on open, but that still requires waiting 10 seconds. </p>