The documentation for AcceptEx()
says:
When this operation is successfully completed, sAcceptSocket can be passed, but to the following functions only:
- ReadFile
- WriteFile
- send
- WSASend
- recv
- WSARecv
- TransmitFile
- closesocket
- setsockopt (only for SO_UPDATE_ACCEPT_CONTEXT)
Notice that shutdown()
is not in the list. Indeed, invoking shutdown(sAcceptSocket, SD_SEND)
returns SOCKET_ERROR
and WSAGetLastError()
produces error WSAENOTCONN
:
A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
Why can you not shutdown a socket connected through AcceptEx()
? Also, why does the socket not appear as connected since it is already receiving data (the overlapped operation has completed and the completion notification indicates that some size>0
bytes were received)?