c++ - what happens if tried to close an already closed socket winsock? -
this question has answer here:
what happen if call closesocket(m_socket) 2 times? after first call socket closed. whether after second call happen not program or application. or return error can ignore.
see http://msdn.microsoft.com/en-us/library/windows/desktop/ms737582(v=vs.85).aspx
note socket descriptor passed in s parameter may reused system closesocket function issued. result, not reliable expect further references socket descriptor passed in s parameter fail error wsaenotsock.
i'd interpret meaning should careful not close socket twice when intermediate code may have done involving descriptor - includes opening files , other sockets - rather necessary blanket prohibition, fragile , should coding avoid possibility. may make sense assign invalid_socket variable you're using hold socket descriptor, allowing check before calling closesocket again or (worse) ensuring side-effect-free failure of second call.
Comments
Post a Comment