chris

chris

  • NA
  • 20
  • 0

Netstat GUI

Feb 10 2009 3:03 PM
Basically I am making a netstat GUI. netstat is a command in the cmd that shows all the IP addresses you are connected with. I coded my app, but for some reason it will only show one IP not all the one's I am connected to.

Here is my code:

        private void button1_Click(object sender, EventArgs e)
        {
            iplist.ReadOnly = true;
            IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
            IPEndPoint[] endPoints = ipProperties.GetActiveTcpListeners();
            TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections();
            //List IPS

            foreach (TcpConnectionInformation info in tcpConnections)
            {
                iplist.Text = ("Local : " + info.LocalEndPoint.Address.ToString()
                + ":" + info.LocalEndPoint.Port.ToString()
                + "\nRemote : " + info.RemoteEndPoint.Address.ToString()
                + ":" + info.RemoteEndPoint.Port.ToString()
                + "\nState : " + info.State.ToString() + "\n\n");
            }

        }

Answers (3)