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");
}
}
Loading
PeterPosted Feb 18, 2009, 4:09 PM
Instead of
iplist.Text = ("Local : " + ...
do
iplist.Text += ("Local : " + ...
i.e. add the plus-sign before "=".
Let me know if it works ;)
You should by any case create a StringBuilder instead, and apply the content of this to ipList.Text. This is more efficient..
chrisPosted Feb 12, 2009, 8:34 PM
chrisPosted Feb 11, 2009, 6:58 AM