TcpClient.SendTimeout Propriedade

Definição

Obtém ou definem o tempo TcpClient de espera para que uma operação de envio seja concluída com sucesso.

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 Propriedade

O valor de time-out de envio, em milissegundos. A predefinição é 0.

Exemplos

O seguinte exemplo de código 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 " + 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

Observações

A SendTimeout propriedade determina o tempo que o Send método irá bloquear até conseguir regressar com sucesso. Este tempo mede-se em milissegundos.

Depois de chamar o Write método, o subjacente Socket devolve o número de bytes realmente enviados para o host. A SendTimeout propriedade determina o tempo de espera TcpClient antes de receber o número de bytes devolvidos. Se o time-out expirar antes de o Send método ser concluído com sucesso, TcpClient lançará um SocketException. Por defeito, não há tempo de espera.

Aplica-se a

Ver também