MSDN Library


Windows Mobile 6.5
A version of this page is also available for

This function disables sends or receives on a socket.

int shutdown(
  int how


[in] Descriptor identifying a socket.


[in] Flag that describes what types of operation will no longer be allowed.

If no error occurs, this function returns zero. If an error occurs, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError. The following table shows a list of possible error codes.

Error code Description


A successful WSAStartup call must occur before using this function.


The network subsystem has failed.


The how parameter is not valid or is not consistent with the socket type. For example, SD_SEND is used with a UNI_RECV socket type.


A blocking Winsock call is in progress, or the service provider is still processing a callback function.


The socket is not connected (connection-oriented sockets only).


The descriptor is not a socket.

This function is used on all types of sockets to disable reception, transmission, or both.

If the how parameter is SD_RECEIVE, subsequent calls to the recv function on the socket will be disallowed. This has no effect on the lower protocol layers. For TCP sockets, if there is still data queued on the socket waiting to be received, or data arrives subsequently, the connection is reset because the data cannot be delivered to the user. For UDP sockets, incoming datagrams are accepted and queued. In no case will an Internet Control Message Protocol (ICMP) error packet be generated.

If the how parameter is SD_SEND, subsequent calls to the send function are disallowed. For TCP sockets, a FIN will be sent after all data is sent and acknowledged by the receiver.

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

The shutdown function does not close the socket. Any resources attached to the socket will not be freed until closesocket is invoked.

To ensure that all data is sent and received on a connected socket before it is closed, an application should use shutdown to close the connection before calling closesocket.

The shutdown function does not block regardless of the SO_LINGER setting on the socket.

An application should not rely on being able to reuse a socket after it has been shut down. In particular, a Windows Sockets provider is not required to support the use of the connect (Windows Sockets) function on a socket that has been shut down.

Asynchronous transfer mode (ATM) is not supported in Windows Embedded CE.

Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

© 2016 Microsoft