TcpClient.ReceiveTimeout プロパティ

定義

読み取り操作が開始された後に TcpClient がデータの受信を待機する時間を取得または設定します。

public:
 property int ReceiveTimeout { int get(); void set(int value); };
public int ReceiveTimeout { get; set; }
member this.ReceiveTimeout : int with get, set
Public Property ReceiveTimeout As Integer

プロパティ値

接続のタイムアウト値 (ミリ秒単位)。 既定値は 0 です。

次のコード例では、受信タイムアウトを設定して取得します。

// Sets the receive time out using the ReceiveTimeout public property.
tcpClient->ReceiveTimeout = 5;

// Gets the receive time out using the ReceiveTimeout public property.
if ( tcpClient->ReceiveTimeout == 5 )
      Console::WriteLine( "The receive time out limit was successfully set {0}", tcpClient->ReceiveTimeout );
// Sets the receive time out using the ReceiveTimeout public property.
tcpClient.ReceiveTimeout = 5000;

// Gets the receive time out using the ReceiveTimeout public property.
if (tcpClient.ReceiveTimeout == 5000)
    Console.WriteLine ("The receive time out limit was successfully set " + tcpClient.ReceiveTimeout.ToString ());
' Sets the receive time out using the ReceiveTimeout public property.
tcpClient.ReceiveTimeout = 5

' Gets the receive time out using the ReceiveTimeout public property.
If tcpClient.ReceiveTimeout = 5 Then
   Console.WriteLine(("The receive time out limit was successfully set " + tcpClient.ReceiveTimeout.ToString()))
End If

注釈

プロパティは ReceiveTimeout 、データを受信できるようになるまでメソッドが Read ブロックする時間を決定します。 この時間はミリ秒単位で測定されます。 タイムアウトが正常に完了する前に Read 期限切れになった場合は、 TcpClientIOExceptionスローします。 既定ではタイムアウトはありません。

適用対象

こちらもご覧ください