TcpState 열거형

정의

TCP(Transmission Control Protocol) 연결의 상태를 나타냅니다.

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정의되어 있습니다.

적용 대상