See http://msdn.microsoft.com/en-us/library/windows/desktop/ms737582(v=vs.85).aspx
Note that the socket descriptor passed in the s parameter can be immediately reused by the system as soon as the closesocket function is started. As a result, it is unreliable to expect that further socket descriptor references passed in parameter s will fail with a WSAENOTSOCK error.
I would interpret this as a value, so you have to be careful not to close the socket twice when any intermediate code could do anything including a descriptor that includes opening files and other sockets, rather than a necessary blanket ban but actually it is fragile and you have to be coding to avoid the possibility. It might make sense to assign INVALID_SOCKET to the variable you are using to store the socket descriptor, allowing you to verify this before calling closesocket again or (even worse) to ensure that the side effect of this second call is not rejected.
source share