Get Transport Control Protocol Information

Code To get transport control protocol information.

using System;

using System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Net.NetworkInformation;
using
System.Net; 

namespace Network

{
    public class
TcpConnectionInfo

    {

        public string GetNetworkInformation()

        {

            System.Text.StringBuilder strBldr = new System.Text.StringBuilder();

           
try

            {

                strBldr.Append("Current IP Connections:" + Environment.NewLine);

                foreach (TcpConnectionInformation tcpConnection in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections())

                {

                    strBldr.Append("" + "\t" + " Connection Info:" + Environment.NewLine);

                    strBldr.Append("" + "\t" + "" + "\t" + " Remote Address: " + tcpConnection.RemoteEndPoint.Address.ToString() +
Environment.NewLine);

                    strBldr.Append("" + "\t" + "" + "\t" + " State: ".PadRight(17) + tcpConnection.State.ToString() + Environment.NewLine);

                }

            }

           
catch

            {

            }

            return strBldr.ToString();

        } 

    }

}
Ebook Download
View all
Learn
View all