title: In C#, how to check if a TCP port is available?
body: <p>In C# to use a TcpClient or generally to connect to a socket how can I first check if a certain port is free on my machine?</p>
  
  <p><em>more info:</em>
  This is the code I use:</p>
  
  <pre><code>TcpClient c;
  //I want to check here if port is free.
  c = new TcpClient(ip, port);
  </code></pre>