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 */
public int get_SendTimeout ()

/** @property */
public void set_SendTimeout (int value)

public function get SendTimeout () : int

public function set SendTimeout (value : int)

Not applicable.

Property Value

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 2003 for Pocket PC, Windows Mobile 2003 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.

// 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.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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft