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.

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

Property Value

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

Remarks

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 succussfully 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 SendTimeout value.

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


[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(S"The send time out limit was successfully set {0}", __box(tcpClient->SendTimeout));

[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 | Write | ReceiveTimeout

Show:
© 2014 Microsoft