TcpClient.SendTimeout 屬性

定義

取得或設定時間值,TcpClient 將據此等候傳送作業成功完成。

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

屬性值

Int32

傳送的逾時值,以毫秒為單位。 預設值是 0。

範例

下列程式碼範例會設定並取得 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 {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

備註

屬性 SendTimeout 會決定方法將封鎖的時間量, Send 直到能夠成功傳回為止。 這個時間是以毫秒為單位來測量。

呼叫 Write 方法之後,基礎 Socket 會傳回實際傳送至主機的位元組數目。 屬性 SendTimeoutTcpClient 決定 在接收傳回的位元組數目之前,將等候的時間量。 如果逾時在方法成功完成之前 Send 到期, TcpClient 將會擲回 SocketException 。 預設不會逾時。

適用於

另請參閱