0

I have application that is running TCP server. To initialize TCP I run WSAStartup(). Then I need to load third party dll. Dll is also does some TCP job and has some bug - it runs WSACleanup() without running WSAStartup(). This bug brakes my TCP server since dll's WSACleanup() kills it.

I can't fix dll. How to avoid this situation. Looks run use dll and my TCP server in different threads doesn't helps

MD XF
  • 7,062
  • 7
  • 34
  • 64
vico
  • 13,725
  • 30
  • 108
  • 237
  • Don't know if it would make a difference, but could you defer your call to `WSAStartup()` until after you've loaded the 3rd-party DLL? – TripeHound Apr 22 '14 at 09:51

1 Answers1

1

As you can see in the WSAStartup doc, the WSAStartup/WSACleanup perform internal reference counting. Therefore all you need to do is call WSAStartup twice.

Thus, when your library calls WSACleanup, it will only reduce the internal count by one and not release all resources.

gha.st
  • 10,236
  • 1
  • 33
  • 57