TcpClient.SendTimeout Propriedade

Definição

Obtém ou define a quantidade de tempo que um TcpClient aguardará para que uma operação de envio seja concluída com êxito.

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 da propriedade

O valor de tempo limite de envio, em milissegundos. O padrão é 0.

Exemplos

O exemplo de código a seguir define e obtém o 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

Comentários

A SendTimeout propriedade determina a quantidade de tempo que o Send método bloqueará até que seja capaz de retornar com êxito. Esse tempo é medido em milissegundos.

Depois de chamar o Write método , o subjacente Socket retorna o número de bytes realmente enviados para o host. A SendTimeout propriedade determina a quantidade de tempo que um TcpClient aguardará antes de receber o número de bytes retornados. Se o tempo limite expirar antes que o Send método seja concluído com êxito, TcpClient gerará um SocketException. Não há tempo limite por padrão.

Aplica-se a

Confira também