1

Apparently, whenever the closesocket function fails with WSAENETDOWN, “The network subsystem has failed”. But what exactly does that mean? When does it happen? If it does happen, is the socket descriptor still closed? How should I handle it?

Regarding my first question, the Windows Sockets Error Codes page says that WSAENETDOWN means

Network is down.

A socket operation encountered a dead network. This could indicate a serious failure of the network system (that is, the protocol stack that the Windows Sockets DLL runs over), the network interface, or the local network itself.

But that does not really help me either.

Note that POSIX ENETDOWN is only specified for connect, send, sendto, sendmsg, write, not for close. The Winsock counterpart is more ubiquitous.

Community
  • 1
  • 1
purefanatic
  • 933
  • 2
  • 8
  • 23
  • I didn't think you could still get that error code on modern versions of Windows, unless perhaps you had a third-party socket implementation installed. Under what circumstances are you seeing it? – Harry Johnston Sep 06 '16 at 01:36
  • @HarryJohnston I should have added that I have yet to witness this error condition, so this question might be a bit hypothetical (but then again, I did not use Winsock that much yet, so I just wanted to be sure). Does this also apply to `WSACleanup`? It would be nice if you could provide some reference and maybe an answer, too! – purefanatic Sep 06 '16 at 09:02
  • On second thoughts, Winsock might well return that error code if the TCP/IP driver crashed or was stopped. (You could try `sc stop tcpip` while your program has a socket open, if you wanted to experiment.) At any rate, it is unlikely that your program can resolve the problem. You should probably assume that the socket is no longer valid; if it leaks, well, that's not your fault, it won't happen under normal circumstances and there isn't anything you can sensibly do about it. – Harry Johnston Sep 06 '16 at 21:48

0 Answers0