次の方法で共有


TcpClient.SendTimeout プロパティ

送信操作が正常に完了するのを TcpClient が待機する時間を取得または設定します。

Public Property SendTimeout As Integer
[C#]
public int SendTimeout {get; set;}
[C++]
public: __property int get_SendTimeout();public: __property void set_SendTimeout(int);
[JScript]
public function get SendTimeout() : int;public function set SendTimeout(int);

プロパティ値

ミリ秒単位の送信タイムアウト値。既定値は 0 です。

解説

SendTimeout プロパティは、正常に終了できるまで Send メソッドがブロックする時間を決定します。時間の単位はミリ秒です。

Write メソッドを呼び出すと、基になる Socket はホストに実際に送信されたバイト数を返します。 SendTimeout プロパティは、返されたバイト数を受信する前に TcpClient が待機する時間を決定します。 Send メソッドが正常に完了する前にタイムアウトが発生した場合、 TcpClientSocketException をスローします。既定では、タイムアウトは発生しません。

使用例

[Visual Basic, C#, C++] SendTimeout 値を設定および取得する例を次に示します。

 
' Sets the send time out using the SendTimeout public property.
tcpClient.SendTimeout = 5

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

[C#] 
// sets the send time out using the SendTimeout public property.
tcpClient.SendTimeout = 5;

// gets the send time out using the SendTimeout public property.
if (tcpClient.SendTimeout == 5)
    Console.WriteLine ("The send time out limit was successfully set " + tcpClient.SendTimeout.ToString ());


[C++] 
// sets the send time out using the SendTimeout public property.
tcpClient->SendTimeout = 5;

// gets the send time out using the SendTimeout public property.
if (tcpClient->SendTimeout == 5)
     Console::WriteLine(S"The send time out limit was successfully set {0}", __box(tcpClient->SendTimeout));

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

TcpClient クラス | TcpClient メンバ | System.Net.Sockets 名前空間 | Write | ReceiveTimeout