TcpClient.ReceiveTimeout Propriedade

Definição

Obtém ou define a quantidade de tempo que um TcpClient aguardará para receber dados depois que uma operação de leitura for iniciada.Gets or sets the amount of time a TcpClient will wait to receive data once a read operation is initiated.

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

Valor da propriedade

Int32

O valor de tempo limite da conexão em milissegundos.The time-out value of the connection in milliseconds. O valor padrão é 0.The default value is 0.

Exemplos

O exemplo de código a seguir define e Obtém o tempo limite de recebimento.The following code example sets and gets the receive time out.

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

Comentários

A ReceiveTimeout propriedade determina a quantidade de tempo que o Read método bloqueará até que possa receber dados.The ReceiveTimeout property determines the amount of time that the Read method will block until it is able to receive data. Esse tempo é medido em milissegundos.This time is measured in milliseconds. Se o tempo limite expirar antes de Read ser concluído com êxito, o TcpClient lança um IOException .If the time-out expires before Read successfully completes, TcpClient throws a IOException. Não há tempo limite por padrão.There is no time-out by default.

Aplica-se a

Confira também