6

I have a Windows socket program (XP and above) that calls WSAStartup. Is it necessary to call WSACleanup before the program exits? If I don't, will there be any negative consequences? In particular is:

WSACleanup();
exit(0);

different from merely exit(0). I realise that on Win16 omitting the WSACleanup would leak system resources, is that still the case.

MD XF
  • 7,860
  • 7
  • 40
  • 71
Neil Mitchell
  • 9,090
  • 1
  • 27
  • 85
  • 2
    It is not necessary. You do blow the opportunity of ever using any leak diagnostic tool again, best to code carefully in the future :) – Hans Passant Jan 27 '15 at 20:06
  • 2
    @HansPassant, my goal is improving a binding in a garbage collected language, so losing leak diagnostics is not a problem, and calling WSACleanup is added complexity. Any reference to say it is not necessary? It seems "obvious" to me as a general rule of OS design, but I can't find it actually stated. – Neil Mitchell Jan 27 '15 at 21:41

0 Answers0