TcpClient.ReceiveTimeout Propiedad

Definición

Obtiene o establece el período de tiempo durante el cual un TcpClient esperará para recibir datos tras iniciarse una operación de lectura.

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 de propiedad

Valor de tiempo de espera de la conexión, en milisegundos. El valor predeterminado es 0.

Ejemplos

En el ejemplo de código siguiente se establece y se agota el tiempo de espera de recepción.

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

Comentarios

La ReceiveTimeout propiedad determina la cantidad de tiempo que el Read método bloqueará hasta que pueda recibir datos. Este tiempo se mide en milisegundos. Si el tiempo de espera expira antes Read de que finalice correctamente, TcpClient inicia un IOException. No hay tiempo de espera de forma predeterminada.

Se aplica a

Consulte también