HttpWebRequest.Timeout プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HttpWebRequest.Timeout プロパティの意味・解説 

HttpWebRequest.Timeout プロパティ

GetRequestStream メソッドと GetResponse メソッドタイムアウト値を取得または設定します

名前空間: System.Net
アセンブリ: System (system.dll 内)
構文構文

例外例外
例外種類条件

ArgumentOutOfRangeException

指定した値が 0 未満のため Infinite ではありません。

解説解説

Timeout は、GetResponse メソッド行った後続同期要求応答待機する時間を表すミリ秒数です。GetRequestStream メソッドは、ストリーム待機します。リソースタイムアウト時間内に返されない場合要求は WebException をスローし、Status プロパティを WebExceptionStatus.Timeout に設定します

Timeout プロパティは、BeginGetResponse メソッドまたは BeginGetRequestStream メソッド行われた非同期要求には影響与えません。

注意に関するメモ注意

非同期要求場合は、クライアント アプリケーションが独自のタイムアウト機構実装ます。BeginGetResponse メソッドの例を参照してください

読み取り操作または書き込み操作タイムアウトするまでの待機時間指定するには、ReadWriteTimeout プロパティ使用します

ドメイン ネーム システム (DNS: Domain Name System) クエリが値を返すか、タイムアウトするまでに、最大15 秒かかることがあります解決する必要があるホスト名要求含まれている場合Timeout15未満の値に設定していても、要求タイムアウトを示す WebExceptionスローされるまでに 15 秒以上かかることがあります

使用例使用例

HttpWebRequest オブジェクトTimeout プロパティ設定するコード例次に示します

' Create a new 'HttpWebRequest' Object to the mentioned URL.
     Dim myHttpWebRequest As HttpWebRequest
 = CType(WebRequest.Create("http://www.contoso.com"),
 HttpWebRequest)
     Console.WriteLine(ControlChars.Cr + "The timeout time of
 the request before setting the property is  {0}  milliSeconds", myHttpWebRequest.Timeout)
    ' Set the  'Timeout' property of the HttpWebRequest to 10 milliseconds.
 myHttpWebRequest.Timeout = 10    
     ' Display the 'Timeout' property of the 'HttpWebRequest' on the
 console.
     Console.WriteLine(ControlChars.Cr + "The timeout time of
 the request after setting the timeout is {0}  milliSeconds", myHttpWebRequest.Timeout)
     ' A HttpWebResponse object is created and is GetResponse Property
 of the HttpWebRequest associated with it 
     Dim myHttpWebResponse As HttpWebResponse
 = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
// Create a new 'HttpWebRequest' Object to the mentioned URL.
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create("http://www.contoso.com");
Console.WriteLine("\nThe timeout time of the request before setting the property
 is  {0}  milliSeconds.",myHttpWebRequest.Timeout);
// Set the  'Timeout' property of the HttpWebRequest to 10 milliseconds.
myHttpWebRequest.Timeout=10;
// Display the 'Timeout' property of the 'HttpWebRequest' on the console.
Console.WriteLine("\nThe timeout time of the request after setting the timeout
 is {0}  milliSeconds.",myHttpWebRequest.Timeout);
// A HttpWebResponse object is created and is GetResponse Property of
 the HttpWebRequest associated with it 
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();
// Create a new 'HttpWebRequest' Object to the mentioned URL.
HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com"
 ) );
Console::WriteLine( "\nThe timeout time of the request before setting the property
 is {0} milliseconds.", myHttpWebRequest->Timeout );
// Set the  'Timeout' property of the HttpWebRequest to 10 milliseconds.
myHttpWebRequest->Timeout = 10;
// Display the 'Timeout' property of the 'HttpWebRequest' on the console.
Console::WriteLine( "\nThe timeout time of the request after setting the timeout
 is {0} milliseconds.", myHttpWebRequest->Timeout );
// A HttpWebResponse object is created and is GetResponse Property of
 the HttpWebRequest associated with it
HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse()
 );
// Create a new 'HttpWebRequest' Object to the mentioned URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)
    WebRequest.Create("http://www.contoso.com");
Console.WriteLine("\nThe timeout time of the request before"
    + " setting the property is  {0}  milliSeconds.", 
    System.Convert.ToString(myHttpWebRequest.get_Timeout()));

// Set the  'Timeout' property of the HttpWebRequest to 10 milli 
// seconds.
myHttpWebRequest.set_Timeout(10);
// Display the 'Timeout' property of the 'HttpWebRequest' on 
// the console.
Console.WriteLine("\nThe timeout time of the request after setting"
    + " the timeout is {0}  milliSeconds.", 
    System.Convert.ToString(myHttpWebRequest.get_Timeout()));
// A HttpWebResponse object is created and is GetResponse Property 
//of the HttpWebRequest associated with it 
HttpWebResponse myHttpWebResponse = (HttpWebResponse)
    myHttpWebRequest.GetResponse();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HttpWebRequest クラス
HttpWebRequest メンバ
System.Net 名前空間
HttpWebRequest.ReadWriteTimeout プロパティ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「HttpWebRequest.Timeout プロパティ」の関連用語

HttpWebRequest.Timeout プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HttpWebRequest.Timeout プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS