TcpState 列挙型

定義

伝送制御プロトコル (TCP) 接続の状態を示します。

public enum class TcpState
public enum TcpState
type TcpState = 
Public Enum TcpState
継承
TcpState

フィールド

Closed 1

TCP 接続が閉じています。

CloseWait 8

TCP 接続のローカル エンドポイントがローカル ユーザーからの接続終了要求を待機しています。

Closing 9

TCP 接続のローカル エンドポイントが既に送信された接続終了要求の受信確認を待機しています。

DeleteTcb 12

TCP 接続の伝送制御バッファー (TCB: Transmission Control Buffer) が削除されます。

Established 5

TCP ハンドシェイクが完了しています。 接続が確立されているため、データを送信できます。

FinWait1 6

TCP 接続のローカル エンドポイントがリモート エンドポイントからの接続終了要求、または既に送信された接続終了要求の受信確認を待機しています。

FinWait2 7

TCP 接続のローカル エンドポイントがリモート エンドポイントからの接続終了要求を待機しています。

LastAck 10

TCP 接続のローカル エンドポイントが既に送信された接続終了要求の最終受信確認を待機しています。

Listen 2

TCP 接続のローカル エンドポイントがリモート エンドポイントからの接続要求を待機しています。

SynReceived 4

TCP 接続のローカル エンドポイントが接続要求の送受信を行い、受信確認を待機しています。

SynSent 3

TCP 接続のローカル エンドポイントが、リモート エンドポイントに同期 (SYN) 制御ビットを設定したセグメント ヘッダーを送信し、一致する接続要求を待機しています。

TimeWait 11

TCP 接続のローカル エンドポイントが、リモート エンドポイントが確実に接続終了要求の受信確認を受信できるだけの期間、待機しています。

Unknown 0

TCP 接続の状態が不明です。

次のコード例では、確立された TCP 接続をカウントします。

void CountTcpConnections()
{
   IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties();
   array<TcpConnectionInformation^>^connections = properties->GetActiveTcpConnections();
   int establishedConnections = 0;
   System::Collections::IEnumerator^ myEnum1 = connections->GetEnumerator();
   while ( myEnum1->MoveNext() )
   {
      TcpConnectionInformation ^ t = safe_cast<TcpConnectionInformation ^>(myEnum1->Current);
      if ( t->State == TcpState::Established )
      {
         establishedConnections++;
      }

      Console::Write( "Local endpoint: {0} ", t->LocalEndPoint->Address );
      Console::WriteLine( "Remote endpoint: {0} ", t->RemoteEndPoint->Address );
   }

   Console::WriteLine( "There are {0} established TCP connections.", establishedConnections );
}
public static void CountTcpConnections()
{
    IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
    TcpConnectionInformation[] connections = properties.GetActiveTcpConnections();
    int establishedConnections = 0;

    foreach (TcpConnectionInformation t in connections)
    {
        if (t.State == TcpState.Established)
        {
             establishedConnections++;
        }
        Console.Write("Local endpoint: {0} ",t.LocalEndPoint.Address);
        Console.WriteLine("Remote endpoint: {0} ",t.RemoteEndPoint.Address);
    }
     Console.WriteLine("There are {0} established TCP connections.",
        establishedConnections);
}
Public Shared Sub CountTcpConnections() 
    Dim properties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
    Dim connections As TcpConnectionInformation() = properties.GetActiveTcpConnections()
    Dim establishedConnections As Integer = 0
    
    Dim t As TcpConnectionInformation
    For Each t In  connections
        If t.State = TcpState.Established Then
            establishedConnections += 1
        End If
        Console.Write("Local endpoint: {0} ", t.LocalEndPoint.Address)
        Console.WriteLine("Remote endpoint: {0} ", t.RemoteEndPoint.Address)
    Next t 
    Console.WriteLine("There are {0} established TCP connections.", establishedConnections)

End Sub

注釈

この列挙は、 プロパティの有効な値を State 定義します。 TCP は、データ パケットの確実な送受信を担当するトランスポート層プロトコルです。 この列挙の TCP 状態は、 で使用可能な IETF RFC 793 で https://www.ietf.org定義されています。

適用対象