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 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈