I am using VC6, SP5 and am getting a strange error when using gethostbyname() in a thread. It is a worker thread and messaging is fully active. Yet when I access gethostbyname() I get a NULL returned and WSAGetLastError() immediately afterwards indicates a WSANOTINITIALISED error.
Digging into the on-line literature reveals that WSAStartup() either was not called or it failed. The problem is that it was called and it did not fail. It was also called at the start of the thread. I replaced that with AfxSocketInit() and get exactly the same error. This used to work fine and it seems that after Service Pack 5 came into the picture I get this problem. That seems a bit much to believe.
What can be causing this? How can it be resolved?