Enumerate all open connections

Is it possible to enumerate all open connections of the current process using .NET? (similarly to the way the netstat tool does this)


        IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
        TcpConnectionInformation[] connections = properties.GetActiveTcpConnections();

you have to convert this array to IEnum

You can do this with the IPGlobalProperties class in .NET. With an instance, you can get any of the three things that netstat generally shows:

Note that there's no such thing as a "UDP connection".

Here's a simple version of netstat, using this API:

using System;
using System.Net.NetworkInformation;

namespace NetStatNet
    class Program
        static void Main(string[] args)
            var props = IPGlobalProperties.GetIPGlobalProperties();

            Console.WriteLine("  Proto  Local Address          Foreign Address        State");

            foreach (var conn in props.GetActiveTcpConnections())
                Console.WriteLine("  TCP    {0,-23}{1,-23}{2}",
                                  conn.LocalEndPoint, conn.RemoteEndPoint, conn.State);

            foreach (var listener in props.GetActiveTcpListeners())
                Console.WriteLine("  TCP    {0,-23}{1,-23}{2}", listener, "", "Listening");

            foreach (var listener in props.GetActiveUdpListeners())
                Console.WriteLine("  UDP    {0,-23}{1,-23}{2}", listener, "", "Listening");


Need Your Help

C# display pdf document in iframe in asp.net page

c# asp.net iframe

how can i display pdf document in iframe in c# web page:i have a drowpdownlist linked with pdf files,what i need is when i select one item from this list ,iframe will populated with the correspondi...

Limitations of implicit resolution or type inference

scala type-inference implicit-conversion

I'm trying to understand why implicit resolution (or perhaps type inference) fails for the following Scala code. In this code, compilation fails on the second to last line, but succeeds on a modified

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.