Aracılığıyla paylaş


HttpListenerRequest.KeepAlive Özellik

Tanım

İstemcinin kalıcı bir Boolean bağlantı isteyip istemediğinizi belirten bir değer alır.

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

Özellik Değeri

true bağlantının açık tutulması gerekiyorsa; aksi takdirde , false.

Örnekler

Aşağıdaki kod örneği bu özelliğin kullanılmasını gösterir.

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

Açıklamalar

Bir HTTP istemcisi ve sunucusu kısa bir süre içinde birden çok kez veri alışverişinde bulunmayı bekliyorsa, kalıcı bir bağlantı her ileti için tcp bağlantısını açmak ve kapatmak için gereken ek yükü önlemelerine izin vererek iletişimlerini hızlandırır. HTTP/1.1 kullanan istemciler için, bu özelliğin varsayılan değeri şeklindedir true.

Şunlara uygulanır

Ayrıca bkz.