Langue

IPGlobalProperties.GetActiveTcpConnections Méthode

Définition

Retourne des informations sur les connexions TCP (Transmission Control Protocol) IPv4 (Internet Protocol) et IPv6 sur l’ordinateur local.

public:
 abstract cli::array <System::Net::NetworkInformation::TcpConnectionInformation ^> ^ GetActiveTcpConnections();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.TcpConnectionInformation[] GetActiveTcpConnections();
public abstract System.Net.NetworkInformation.TcpConnectionInformation[] GetActiveTcpConnections();
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
abstract member GetActiveTcpConnections : unit -> System.Net.NetworkInformation.TcpConnectionInformation[]
abstract member GetActiveTcpConnections : unit -> System.Net.NetworkInformation.TcpConnectionInformation[]
Public MustOverride Function GetActiveTcpConnections () As TcpConnectionInformation()

Retours

Tableau TcpConnectionInformation qui contient des objets qui décrivent les connexions TCP actives ou un tableau vide si aucune connexion TCP active n’est détectée.

Attributs

Exceptions

Échec de la fonction GetTcpTable Win32.

Exemples

L’exemple suivant affiche les informations de point de terminaison pour les connexions TCP actives.

public static void ShowActiveTcpConnections()
{
           Console.WriteLine("Active TCP Connections");
           IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
           TcpConnectionInformation[] connections = properties.GetActiveTcpConnections();
           foreach (TcpConnectionInformation c in connections)
           {
               Console.WriteLine("{0} <==> {1}",
                   c.LocalEndPoint.ToString(),
                   c.RemoteEndPoint.ToString());
           }
}

Remarques

Les objets retournés par cette méthode incluent des connexions dans tous les états TCP, à l’exception de l’état Listen . Vous pouvez vérifier l’état d’une connexion en appelant State.

Le protocole TCP est défini dans IETF RFC 793. Notez que les objets retournés par cette méthode reflètent les connexions au moment de la création du tableau. Ces informations ne sont pas mises à jour dynamiquement.

S’applique à