TcpClient.SendTimeout Właściwość

Definicja

Pobiera lub ustawia czas TcpClient oczekiwania na pomyślne zakończenie operacji wysyłania.

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

Wartość właściwości

Wartość limitu czasu wysyłania w milisekundach. Wartość domyślna to 0.

Przykłady

Poniższy przykład kodu ustawia i pobiera SendTimeout wartość.

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

Uwagi

Właściwość SendTimeout określa ilość czasu, przez którą Send metoda zostanie zablokowana do momentu pomyślnego zwrócenia jej. Ten czas jest mierzony w milisekundach.

Po wywołaniu metody bazowa WriteSocket zwraca liczbę bajtów rzeczywiście wysłanych do hosta. Właściwość SendTimeout określa ilość czasu TcpClient oczekiwania przed otrzymaniem liczby zwracanych bajtów. Jeśli limit czasu wygaśnie przed pomyślnym zakończeniem Send metody, TcpClient zostanie zgłoszony błąd SocketException. Domyślnie nie ma limitu czasu.

Dotyczy

Zobacz też