I just want to close or disconnect (I don't know what is the right term for kicking a certain ip address from a network) using IPGlobalProperties and TcpConnectionInformation
IPGlobalProperties properties;
TcpConnectionInformation[] connections =
{
};
string[] splitIpAndPort = { };
List<string> listOfIP = new List<string>();
try
{
properties = IPGlobalProperties.GetIPGlobalProperties();
connections = properties.GetActiveTcpConnections();
foreach (TcpConnectionInformation c in connections)
{
splitIpAndPort = c.RemoteEndPoint.ToString().Split(':');
foreach (string z in splitIpAndPort)
{
listOfIP.Add(z);
if(listOfIP.Contains("192.168.2.1") && splitIpAndPort[1].Contains("5001"))
{
//kick, disconnect or close
}
}
}
}
catch (System.Exception)
{
}
Is this possible? Thanks in advance.