TcpClient.ReceiveTimeout Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the amount of time a TcpClient will wait to receive data once a read operation is initiated.
public:
property int ReceiveTimeout { int get(); void set(int value); };
public int ReceiveTimeout { get; set; }
member this.ReceiveTimeout : int with get, set
Public Property ReceiveTimeout As Integer
Property Value
The time-out value of the connection in milliseconds. The default value is 0.
Examples
The following code example sets and gets the receive time out.
// Sets the receive time out using the ReceiveTimeout public property.
tcpClient->ReceiveTimeout = 5;
// Gets the receive time out using the ReceiveTimeout public property.
if ( tcpClient->ReceiveTimeout == 5 )
Console::WriteLine( "The receive time out limit was successfully set {0}", tcpClient->ReceiveTimeout );
// Sets the receive time out using the ReceiveTimeout public property.
tcpClient.ReceiveTimeout = 5000;
// Gets the receive time out using the ReceiveTimeout public property.
if (tcpClient.ReceiveTimeout == 5000)
Console.WriteLine ("The receive time out limit was successfully set " + tcpClient.ReceiveTimeout.ToString ());
' Sets the receive time out using the ReceiveTimeout public property.
tcpClient.ReceiveTimeout = 5
' Gets the receive time out using the ReceiveTimeout public property.
If tcpClient.ReceiveTimeout = 5 Then
Console.WriteLine(("The receive time out limit was successfully set " + tcpClient.ReceiveTimeout.ToString()))
End If
Remarks
The ReceiveTimeout
property determines the amount of time that the Read method will block until it is able to receive data. This time is measured in milliseconds. If the time-out expires before Read
successfully completes, TcpClient throws a IOException. There is no time-out by default.