Breyta

Deila með


NetworkStream.Close Method

Definition

Overloads

Close()

Closes the NetworkStream.

Close(Int32)

Closes the NetworkStream after waiting the specified time to allow data to be sent.

Close(TimeSpan)

Closes the NetworkStream after waiting the specified amount of time to allow data to be sent.

Close()

Closes the NetworkStream.

public:
 override void Close();
public override void Close ();
override this.Close : unit -> unit
Public Overrides Sub Close ()

Examples

The following code example closes the NetworkStream.

' Example for closing the NetworkStream.
' Close the NetworkStream
myNetworkStream.Close()
// Example for closing the NetworkStream.

// Close the NetworkStream
myNetworkStream.Close();
// Example for closing the NetworkStream.
// Close the NetworkStream
myNetworkStream->Close();

Remarks

The Close method frees both unmanaged and managed resources associated with the NetworkStream. If the NetworkStream owns the underlying Socket, it is closed as well.

If a NetworkStream was associated with a TcpClient, the Close method will close the TCP connection, but not dispose of the associated TcpClient.

Applies to

Close(Int32)

Source:
NetworkStream.cs
Source:
NetworkStream.cs
Source:
NetworkStream.cs

Closes the NetworkStream after waiting the specified time to allow data to be sent.

public:
 void Close(int timeout);
public void Close (int timeout);
override this.Close : int -> unit
Public Sub Close (timeout As Integer)

Parameters

timeout
Int32

A 32-bit signed integer that specifies the number of milliseconds to wait to send any remaining data before closing.

Exceptions

The timeout parameter is less than -1.

Remarks

The Close method frees both unmanaged and managed resources associated with the NetworkStream. If the NetworkStream owns the underlying Socket, it is closed as well.

If a NetworkStream was associated with a TcpClient, the Close method will close the TCP connection, but not dispose of the associated TcpClient.

Applies to

Close(TimeSpan)

Source:
NetworkStream.cs
Source:
NetworkStream.cs
Source:
NetworkStream.cs

Closes the NetworkStream after waiting the specified amount of time to allow data to be sent.

public:
 void Close(TimeSpan timeout);
public void Close (TimeSpan timeout);
override this.Close : TimeSpan -> unit
Public Sub Close (timeout As TimeSpan)

Parameters

timeout
TimeSpan

The amount of time to wait to send any remaining data before closing.

Exceptions

timeout is less than -1 milliseconds or greater than MaxValue milliseconds.

Remarks

The Close method frees both unmanaged and managed resources associated with the NetworkStream. If the NetworkStream owns the underlying Socket, it is closed as well. If a NetworkStream was associated with a TcpClient, the Close(Int32) method will close the TCP connection, but not dispose of the associated TcpClient.

Applies to