다음을 통해 공유


Socket.IsBound 속성

정의

Socket이 특정 로컬 포트에 바인딩되었는지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsBound { bool get(); };
public bool IsBound { get; }
member this.IsBound : bool
Public ReadOnly Property IsBound As Boolean

속성 값

Socket이 로컬 포트에 바인딩되었으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 IsBound 속성입니다.

static void ConfigureTcpSocket(Socket tcpSocket)
{
    // Don't allow another socket to bind to this port.
    tcpSocket.ExclusiveAddressUse = true;

    // The socket will linger for 10 seconds after
    // Socket.Close is called.
    tcpSocket.LingerState = new LingerOption (true, 10);

    // Disable the Nagle Algorithm for this tcp socket.
    tcpSocket.NoDelay = true;

    // Set the receive buffer size to 8k
    tcpSocket.ReceiveBufferSize = 8192;

    // Set the timeout for synchronous receive methods to
    // 1 second (1000 milliseconds.)
    tcpSocket.ReceiveTimeout = 1000;

    // Set the send buffer size to 8k.
    tcpSocket.SendBufferSize = 8192;

    // Set the timeout for synchronous send methods
    // to 1 second (1000 milliseconds.)
    tcpSocket.SendTimeout = 1000;

    // Set the Time To Live (TTL) to 42 router hops.
    tcpSocket.Ttl = 42;

    Console.WriteLine("Tcp Socket configured:");

    Console.WriteLine($"  ExclusiveAddressUse {tcpSocket.ExclusiveAddressUse}");

    Console.WriteLine($"  LingerState {tcpSocket.LingerState.Enabled}, {tcpSocket.LingerState.LingerTime}");

    Console.WriteLine($"  NoDelay {tcpSocket.NoDelay}");

    Console.WriteLine($"  ReceiveBufferSize {tcpSocket.ReceiveBufferSize}");

    Console.WriteLine($"  ReceiveTimeout {tcpSocket.ReceiveTimeout}");

    Console.WriteLine($"  SendBufferSize {tcpSocket.SendBufferSize}");

    Console.WriteLine($"  SendTimeout {tcpSocket.SendTimeout}");

    Console.WriteLine($"  Ttl {tcpSocket.Ttl}");

    Console.WriteLine($"  IsBound {tcpSocket.IsBound}");

    Console.WriteLine("");
}

설명

소켓은 메서드를 호출 Bind 하여 명시적으로 바인딩되거나, 임시 로컬 포트(운영 체제에서 선택한 1024보다 큰 사용 가능한 포트)를 사용하는 , SendTo또는 ReceiveFrom과 같은 Connect멤버를 호출하여 암시적으로 바인딩되는 경우 로컬 포트에 바인딩된 것으로 간주됩니다. 서버는 클라이언트가 Bind 연결할 수 있도록 메서드를 사용하여 잘 알려진 포트에 바인딩합니다.

적용 대상