Bagikan melalui


TcpClient.ReceiveTimeout Properti

Definisi

Mendapatkan atau mengatur jumlah waktu tunggu TcpClient untuk menerima data setelah operasi baca dimulai.

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

Nilai Properti

Nilai waktu habis koneksi dalam milidetik. Nilai default adalah 0.

Contoh

Contoh kode berikut menetapkan dan mendapatkan waktu terima habis.

// 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

Keterangan

Properti ReceiveTimeout menentukan jumlah waktu yang akan diblokir Read metode hingga dapat menerima data. Kali ini diukur dalam milidetik. Jika waktu habis kedaluwarsa sebelum Read berhasil diselesaikan, TcpClient akan melempar IOException. Tidak ada waktu habis secara default.

Berlaku untuk

Lihat juga