Mono Class Library: System.Net.Sockets.Socket Overview | Members

System.Net.Sockets.Socket.Shutdown Method

Terminates the ability to send or receive data on a connected socket. [Edit]

public void Shutdown (SocketShutdown how)

Parameters

how
One of the values defined in the System.Net.Sockets.SocketShutdown enumeration. [Edit]

Exceptions

TypeReason
System.Net.Sockets.SocketException
Note: For additional information on causes of the SocketException, see the System.Net.Sockets.SocketException class.
[Edit]
ObjectDisposedExceptionThe current instance has been disposed. [Edit]

Remarks

When how is set to SocketShutdown.Send , the socket on the other end of the connection is notified that the current instance will not send any more data. If the Socket.Send(Byte[], int, SocketFlags) method is subsequently called, a System.Net.Sockets.SocketException exception is thrown.

When how is set to SocketShutdown.Receive, the socket on the other end of the connection is notified that the current instance will not receive any more data. After all the data currently queued on the current instance is received, any subsequent calls to the Socket.Receive(Byte[], int, SocketFlags) method cause a System.Net.Sockets.SocketException exception to be thrown.

Setting how to SocketShutdown.Both terminates both sends and receives as described above. Once this occurs, the socket cannot be used.

Note:

To free resources allocated by the current instance, call the Socket.Close method.

Expected common usage is for the Socket.Shutdown(SocketShutdown) method to be called before the Socket.Close method to ensure that all pending data is sent or received.

[Edit]

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0