Esempio n. 1
0
 private void find()
 {
     richTextBox1.Text = "";
     System.Net.NetworkInformation.IPGlobalProperties         network     = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
     System.Net.NetworkInformation.TcpConnectionInformation[] connections = network.GetActiveTcpConnections();
     foreach (System.Net.NetworkInformation.TcpConnectionInformation tcp in connections)
     {
         richTextBox1.Text = richTextBox1.Text + "IP >>> " + "Remote Network Address : " + tcp.RemoteEndPoint.Address + " Local Network Address : " + tcp.LocalEndPoint.Address + " State : " + tcp.State.ToString() + "\n";
     }
 }
Esempio n. 2
0
 private void find()
 {
     richTextBox1.Text = "";
     System.Net.NetworkInformation.IPGlobalProperties         network     = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
     System.Net.NetworkInformation.TcpConnectionInformation[] connections = network.GetActiveTcpConnections();
     foreach (System.Net.NetworkInformation.TcpConnectionInformation tcp in connections)
     {
         richTextBox1.Text = richTextBox1.Text + "IP >>> " + "Remote Network Address : " + tcp.RemoteEndPoint.Address + " Local Network Address : " + tcp.LocalEndPoint.Address + " State : " + tcp.State.ToString() + "\n";
     }
     if (richTextBox1.Text == "")
     {
         richTextBox1.Text = "Unfortunately No Computers Where found On your Current Network, You may Want to check your Network Cables or Windows Networking Settings.";
     }
 }
Esempio n. 3
0
        }     // End Sub TestX11_Shared

        public static void ShowActiveTcpConnections()
        {
            System.Console.WriteLine("Active TCP Connections");
            System.Net.NetworkInformation.IPGlobalProperties properties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();

            // System.Console.WriteLine("Computer name: {0}", properties.HostName);
            // System.Console.WriteLine("Domain name:   {0}", properties.DomainName);
            // System.Console.WriteLine("Node type:     {0:f}", properties.NodeType);
            // System.Console.WriteLine("DHCP scope:    {0}", properties.DhcpScopeName);
            // System.Console.WriteLine("WINS proxy?    {0}", properties.IsWinsProxy);

            System.Net.NetworkInformation.TcpConnectionInformation[] connections = properties.GetActiveTcpConnections();
            foreach (System.Net.NetworkInformation.TcpConnectionInformation c in connections)
            {
                System.Console.WriteLine("{0} <==> {1}",
                                         c.LocalEndPoint.ToString(),
                                         c.RemoteEndPoint.ToString());
            }
        }
Esempio n. 4
0
        private bool IsUsed(int port)
        {
            bool isUsed = false;

            // Evaluate current system tcp connections. This is the same information provided
            // by the netstat command line application, just in .Net strongly-typed object
            // form.  We will look through the list, and if our port we would like to use
            // in our TcpClient is occupied, we will set isAvailable to false.
            System.Net.NetworkInformation.IPGlobalProperties         ipGlobalProperties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
            System.Net.NetworkInformation.TcpConnectionInformation[] tcpConnInfoArray   = ipGlobalProperties.GetActiveTcpConnections();

            foreach (System.Net.NetworkInformation.TcpConnectionInformation tcpi in tcpConnInfoArray)
            {
                if (tcpi.LocalEndPoint.Port == port)
                {
                    isUsed = true;
                    break;
                }
            }

            return(isUsed);
        }
Esempio n. 5
0
        private bool IsTcpIPStill(TcpClient tcpClient)
        {
            System.Net.NetworkInformation.IPGlobalProperties         ipProperties   = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
            System.Net.NetworkInformation.TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections().Where(x => x.LocalEndPoint.Equals(tcpClient.Client.LocalEndPoint) && x.RemoteEndPoint.Equals(tcpClient.Client.RemoteEndPoint)).ToArray();

            if (tcpConnections != null && tcpConnections.Length > 0)
            {
                System.Net.NetworkInformation.TcpState stateOfConnection = tcpConnections.First().State;
                if (stateOfConnection == System.Net.NetworkInformation.TcpState.Established)
                {
                    // Connection is OK
                    return(true);
                }
                else
                {
                    // No active tcp Connection to hostName:port
                    return(false);
                }
            }
            return(false);
        }
Esempio n. 6
0
        private void ScanPorts(string host)
        {
            rtbOutput.Clear();
            try
            {
                System.Net.NetworkInformation.IPGlobalProperties properties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
                IPEndPoint[] tcpEndPoints = properties.GetActiveTcpListeners();
                System.Net.NetworkInformation.TcpConnectionInformation[] tcpConnections = properties.GetActiveTcpConnections();

                tcpConnections.ToList().ForEach(p =>
                {
                    rtbOutput.Text += $"Local = [{p.LocalEndPoint.Address}:{p.LocalEndPoint.Port}]  Remote = [{p.RemoteEndPoint.Address}:{p.RemoteEndPoint.Port}] State = [{p.State}]\n";
                });
            }
            catch (Exception ex)
            {
                PrintSomeLogInfo(ex.Message);
            }
        }