title: how to get list of opened sockets from some process?
body: <p>Windows Resource Monitor have a nice network filter and its easy to get network statistics of some process (TCP connections, port listen,  etc). I tried System.Diagnostics from <a href="https://stackoverflow.com/questions/11039923/how-can-i-get-the-resource-monitor-values-in-net">this</a> , but all examples are about CPU and Memory usage. I found <a href="http://www.codeproject.com/Articles/4298/Getting-active-TCP-UDP-connections-on-a-box" rel="nofollow noreferrer">this</a> project, but it looks dirty and unsafe. The only i need is to get Resource Monitor functionality in my c# project to do something like</p>
  
  <pre><code>var process = new Process("ProcessName");
  var sockets = process.getSockets();
  </code></pre>
  
  <p>Is there any safe and legal solution without byte shifting and pointers?</p>