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 успешного завершения, TcpClient вызывает исключение IOException. По умолчанию время ожидания отсутствует.

Применяется к

См. также раздел