Export (0) Print
Expand All

TcpClient.SendTimeout Property

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)

public int SendTimeout { get; set; }

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.

The following code example sets and gets the SendTimeout value.


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



.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft