HttpListenerResponse.KeepAlive プロパティ
メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。
サーバーが永続的な接続を要求しているかどうかを示す値を取得または設定します。
名前空間: System.Net
アセンブリ: System (system.dll 内)
構文
Dim instance As HttpListenerResponse Dim value As Boolean value = instance.KeepAlive instance.KeepAlive = value
/** @property */ public boolean get_KeepAlive () /** @property */ public void set_KeepAlive (boolean value)
プロパティ値
サーバーが永続的な接続を要求している場合は true。それ以外の場合は false。既定値は true です。


HTTP クライアントおよびサーバーが短期間の間に複数回データを交換する予定がある場合、永続的な接続を使用すると、メッセージごとに TCP 接続を開いて閉じるために必要なオーバーヘッドがなくなるため、通信速度が向上します。永続的な接続は、現在の Web ブラウザと Web サーバー間の通信で広く使用されています。
永続的な接続の詳細については、RTF Editor Web サイト (http://www.rfc-editor.org) にある HTTP/1.1 プロトコルの仕様 (RFC 2616) を参照してください。

// When the client is not authenticated, there is no Identity. if (context.User == null) { message.Append ("<HTML><BODY><p> Hello local user! </p></BODY></HTML>"); } else { // Get the requester's identity. System.Security.Principal.WindowsIdentity identity = WindowsIdentity.GetCurrent(); // Construct the response body. message.AppendFormat ("<HTML><BODY><p> Hello {0}!<br/>", identity.Name); message.AppendFormat ("You were authenticated using {0}.</p>", identity.AuthenticationType); message.Append ("</BODY></HTML>"); } // Configure the response. HttpListenerResponse response = context.Response; // Use the encoding from the response if one has been set. // Otherwise, use UTF8. System.Text.Encoding encoding = response.ContentEncoding; if (encoding == null) { encoding = System.Text.Encoding.UTF8; response.ContentEncoding = encoding; } byte[] buffer = encoding.GetBytes (message.ToString ()); response.ContentLength64 = buffer.Length; response.StatusCode = (int) HttpStatusCode.OK; response.StatusDescription = "OK"; response.ProtocolVersion = new Version ("1.1"); // Don't keep the TCP connection alive; // We don't expect multiple requests from the same client. response.KeepAlive = false; // Write the response body. System.IO.Stream stream = response.OutputStream; stream.Write(buffer, 0, buffer.Length);

Windows 98, Windows Server 2003, Windows XP Media Center Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHttpListenerResponse.KeepAlive プロパティを検索する場合は、下記のリンクをクリックしてください。

- HttpListenerResponse.KeepAlive プロパティのページへのリンク