TcpClient.ReceiveTimeout Właściwość

Definicja

Pobiera lub ustawia czas TcpClient oczekiwania na odbieranie danych po zainicjowaniu operacji odczytu.

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

Wartość właściwości

Wartość limitu czasu połączenia w milisekundach. Wartość domyślna to 0.

Przykłady

Poniższy przykładowy kod ustawia i pobiera limit czasu odbierania.

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

Uwagi

Właściwość ReceiveTimeout określa czas, Read przez jaki metoda będzie blokowana, dopóki nie będzie mogła odbierać danych. Ten czas jest mierzony w milisekundach. Jeśli limit czasu wygaśnie przed Read pomyślnym zakończeniem, TcpClient zgłasza wartość IOException. Domyślnie nie ma limitu czasu.

Dotyczy

Zobacz też