Any suggestions on testing a TCP client listener. What I'm looking for is actual network stats like "payload size", "time-out values", "actual payload bytes received from server". public static void tcpConnect() { int port = 12345;
        IPEndPoint ipep = new IPEndPoint(
                IPAddress.Parse("xx.xx.xx.xx"), port);
        Socket server = new Socket(AddressFamily.InterNetwork,
                SocketType.Stream, ProtocolType.Tcp);
        IPGlobalProperties _ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
        TcpConnectionInformation[] _tcpConnInfoArray = _ipGlobalProperties.GetActiveTcpConnections();
       // bool isAvaiable = true;
        try
        {
            server.Connect(ipep);                   
        }   
        catch (SocketException e)
        {
            Console.WriteLine("Unable to connect to server");
            Console.WriteLine(e.ToString());
            return;
        }
        NetworkStream ns = new NetworkStream(server);
        if (ns.CanRead)
        {
            foreach (TcpConnectionInformation tcpConnInfo in _tcpConnInfoArray)
            {
                if (tcpConnInfo.LocalEndPoint.Port == port)
                {
                    //isAvaiable = false;
                    Console.WriteLine("Error: Can't Read from Port");
                    break;
                }
                Console.Write("Local endpoint: {0} ", tcpConnInfo.LocalEndPoint.Address);
                Console.Write("Remote endpoint: {0} ", tcpConnInfo.RemoteEndPoint.Address);
                Console.Write("{0}", tcpConnInfo.State);
            }
        }
        else 
        {
            Console.WriteLine("Error: Can't Read from Socket");
            ns.Close();
            return;
        }
        while (true)
        {
           string input = Console.ReadLine();
            if (input == "exit")
                break;
            if (ns.CanWrite)
            {
                Console.WriteLine("NS Can write");
                ns.Flush();
            }
        }
        Console.WriteLine("Disconnection from server");
        ns.Close();
        server.Shutdown(SocketShutdown.Both);
        server.Close();
      }       
  }