3
Reply

Netstat GUI

chris

chris

Feb 10 2009 3:03 PM
7.8k
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)