.NET Framework Class Library
TcpClient..::.SendTimeout Property

Updated: November 2007

Gets or sets the amount of time a TcpClient will wait for a send operation to complete successfully.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

Visual Basic (Declaration)
Public Property SendTimeout As Integer
Visual Basic (Usage)
Dim instance As TcpClient
Dim value As Integer

value = instance.SendTimeout

instance.SendTimeout = value
C#
public int SendTimeout { get; set; }
Visual C++
public:
property int SendTimeout {
    int get ();
    void set (int value);
}
J#
/** @property */
public int get_SendTimeout()
/** @property */
public  void set_SendTimeout(int value)
JScript
public function get SendTimeout () : int
public function set SendTimeout (value : int)

Property Value

Type: System..::.Int32

The send time-out value, in milliseconds. The default is 0.

The SendTimeout property determines the amount of time that the Send method will block until it is able to return successfully. This time is measured in milliseconds.

After you call the Write method, the underlying Socket returns the number of bytes actually sent to the host. The SendTimeout property determines the amount of time a TcpClient will wait before receiving the number of bytes returned. If the time-out expires before the Send method successfully completes, TcpClient will throw a SocketException. There is no time-out by default.

Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note:

In .NET Compact Framework applications, the SendTimeout enumeration value is supported but reserved for future use. Because the SendTimeout property uses this enumeration value, it will raise SocketException until the enumeration value is available in a future release of the .NET Compact Framework.

The following code example sets and gets the SendTimeout value.

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

C#
// 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 ());


Visual C++
// 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 );



J#
// sets the send time out using the SendTimeout public property.
tcpClient.set_SendTimeout(5);

// gets the send time out using the SendTimeout public property.
if (tcpClient.get_SendTimeout() == 5) {
    Console.WriteLine("The send time out limit was successfully set "
        + ((Int32)tcpClient.get_SendTimeout()).ToString());
}

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0
Page view tracker