NetworkStream.Close NetworkStream.Close NetworkStream.Close NetworkStream.Close Method

Definition

Overloads

Close() Close() Close() Close()

Closes the NetworkStream.

Close(Int32) Close(Int32) Close(Int32) Close(Int32)

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

Close() Close() Close() 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.

Close(Int32) Close(Int32) Close(Int32) Close(Int32)

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 Int32 Int32 Int32

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

Exceptions

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