NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Socket.Shutdown

Disables sends and receives on a socket.

[Visual Basic]
Public Function Shutdown( _
   ByVal how As Integer _
) As Integer
[C#]
public int Shutdown(
   int how
);
[C++]
public: int Shutdown(
   int how
);
[JScript]
public function Shutdown(
   how : int
) : int;

Parameters

how
The function that will no longer be allowed.

Return Value

0 if the socket was successfully disabled; otherwise, returns an non-zero error code.

Remarks

The SocketShutdown class contains the valid values for how. The valid values are:

Value Description
sdSend Disable sending on this socket.
sdReceive Disable receiving on this socket.
sdBoth Disable both sending and receiving on this socket.

If how is set to SdSend, subsequent calls to Send are not allowed. For TCP sockets a FIN will be sent after all data is sent and acknowledged by the receiver.

If how is set to SdReceive, susequent calls to Receive are not allowed. This has no effect on lower protocol layers. For TCP sockets the connection is reset if there is data waiting to be received or if more data arrives after the socket is disabled. For UDP sockets, datagrams are accepted and queued.

Setting how to SdBoth disables both sends and receives as described above.

A call to Close must be made after the call to Shutdown to finish closing the socket. You should not attempt to reuse the socket.

Example [C#]

If there is a problem disabling the socket, Shutdown will return a non-zero value indicating the error. The following code attempts to disable a socket. If the attempt is unsuccessful, the error code is written to the console.

[C#]

result = aSocket.Shutdown
if (result <> 0)
{
   Console.WriteLine("Winsock error: " + Convert.ToString(Marshal.GetLastWin32Error()) );

}

See Also

Socket Class | Socket Members | System.Net.Sockets Namespace