HttpListenerRequest.KeepAlive 속성

정의

클라이언트에서 영구 연결을 요청하는지 여부를 나타내는 Boolean 값을 가져옵니다.

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

속성 값

연결을 열린 상태로 유지해야 하면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는이 속성을 사용 하 여 보여 줍니다.

public static void ShowRequestProperties2 (HttpListenerRequest request)
{
    Console.WriteLine("KeepAlive: {0}", request.KeepAlive);
    Console.WriteLine("Local end point: {0}", request.LocalEndPoint.ToString());
    Console.WriteLine("Remote end point: {0}", request.RemoteEndPoint.ToString());
    Console.WriteLine("Is local? {0}", request.IsLocal);
    Console.WriteLine("HTTP method: {0}", request.HttpMethod);
    Console.WriteLine("Protocol version: {0}", request.ProtocolVersion);
    Console.WriteLine("Is authenticated: {0}", request.IsAuthenticated);
    Console.WriteLine("Is secure: {0}", request.IsSecureConnection);
}
Public Shared Sub ShowRequestProperties2(ByVal request As HttpListenerRequest)
    Console.WriteLine("KeepAlive: {0}", request.KeepAlive)
    Console.WriteLine("Local end point: {0}", request.LocalEndPoint.ToString())
    Console.WriteLine("Remote end point: {0}", request.RemoteEndPoint.ToString())
    Console.WriteLine("Is local? {0}", request.IsLocal)
    Console.WriteLine("HTTP method: {0}", request.HttpMethod)
    Console.WriteLine("Protocol version: {0}", request.ProtocolVersion)
    Console.WriteLine("Is authenticated: {0}", request.IsAuthenticated)
    Console.WriteLine("Is secure: {0}", request.IsSecureConnection)
End Sub

설명

HTTP 클라이언트와 서버가 짧은 기간 동안 여러 번 데이터를 교환해야 하는 경우 영구 연결은 각 메시지에 대한 TCP 연결을 열고 닫는 데 필요한 오버헤드를 방지하여 통신 속도를 향상합니다. HTTP/1.1을 사용하는 클라이언트의 경우 이 속성의 기본값은 입니다 true.

적용 대상

추가 정보