TcpClient.ReceiveTimeout Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
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.