title: How to get ips that a certain process is connecting to in c#
body: <p>So I am writing a C# program to manage a web server on Windows. I have it so the web server software starts with the users typed in configuration and starts the web server successfully. However, I am struggling with getting the IP addresses that the web server software is connecting to. I am attempting to show incoming and outgoing connection IPs of a certain exe but am only able to show all incoming outgoing connections of the whole computer not just one specific process exe like I am trying to. Here is the code where I am attempting to do this:</p>
  <pre><code>private void ipmonitor_Click(object sender, EventArgs e)
          {
              
              IPAddress[] addrList = Dns.GetHostByName(Dns.GetHostName()).AddressList;
              string IP = addrList[0].ToString();
              richTextBox2.Text = IP;
          }
      }
      }
      
  </code></pre>
  <p>Is there a way to do this in C# code? Thanks.</p>