TcpClient.SendTimeout Propiedad

Definición

Obtiene o establece el período de tiempo durante el cual un TcpClient esperará para que finalice correctamente una operación de envío.

public:
 property int SendTimeout { int get(); void set(int value); };
public int SendTimeout { get; set; }
member this.SendTimeout : int with get, set
Public Property SendTimeout As Integer

Valor de propiedad

Int32

Valor de tiempo de espera de envío, en milisegundos. El valor predeterminado es 0.

Ejemplos

En el ejemplo de código siguiente se establece y obtiene el SendTimeout valor .

// sets the send time out using the SendTimeout public property.
tcpClient->SendTimeout = 5;

// gets the send time out using the SendTimeout public property.
if ( tcpClient->SendTimeout == 5 )
      Console::WriteLine( "The send time out limit was successfully set {0}", tcpClient->SendTimeout );
// sets the send time out using the SendTimeout public property.
tcpClient.SendTimeout = 5;

// gets the send time out using the SendTimeout public property.
if (tcpClient.SendTimeout == 5)
    Console.WriteLine ("The send time out limit was successfully set " + tcpClient.SendTimeout.ToString ());
' Sets the send time out using the SendTimeout public property.
tcpClient.SendTimeout = 5000

' Gets the send time out using the SendTimeout public property.
If tcpClient.SendTimeout = 5000 Then
   Console.WriteLine(("The send time out limit was successfully set " + tcpClient.SendTimeout.ToString()))
End If

Comentarios

La SendTimeout propiedad determina la cantidad de tiempo que el Send método bloqueará hasta que pueda devolverse correctamente. Este tiempo se mide en milisegundos.

Después de llamar al Write método , el subyacente Socket devuelve el número de bytes que se envían realmente al host. La SendTimeout propiedad determina la cantidad de tiempo que esperará antes TcpClient de recibir el número de bytes devueltos. Si el tiempo de espera expira antes de que se complete correctamente el Send método, TcpClient producirá una SocketExceptionexcepción . No hay tiempo de espera de forma predeterminada.

Se aplica a

Consulte también