Export (0) Print
Expand All

TcpClient.ReceiveTimeout Property

Gets or sets the amount of time a TcpClient will wait to receive data once a read operation is initiated.

[Visual Basic]
Public Property ReceiveTimeout As Integer
[C#]
public int ReceiveTimeout {get; set;}
[C++]
public: __property int get_ReceiveTimeout();
public: __property void set_ReceiveTimeout(int);
[JScript]
public function get ReceiveTimeout() : int;
public function set ReceiveTimeout(int);

Property Value

The time-out value of the connection in milliseconds. The default value is 0.

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 will throw a SocketException. There is no time-out by default.

Example

[Visual Basic, C#, C++] The following example sets and gets the receive time out.

[Visual Basic] 
' 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

[C#] 
// 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 " + tcpClient.ReceiveTimeout.ToString ());


[C++] 
// 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(S"The receive time out limit was successfully set {0}", __box(tcpClient->ReceiveTimeout));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

TcpClient Class | TcpClient Members | System.Net.Sockets Namespace | Read | SendTimeout

Show:
© 2014 Microsoft