TcpClient.SendTimeout 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定時間值,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
屬性值
傳送的逾時值,以毫秒為單位。 預設值是 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 會傳回實際傳送給主機的位元元組數目。 屬性 SendTimeout
會決定 在接收傳回的位元組數目之前,將等候的時間 TcpClient 量。 如果逾時在方法成功完成之前 Send
到期, TcpClient
將會擲回 SocketException。 預設不會逾時。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應