Click to See Complete Forum and Search --> : "NT service compiled staticly and CAsyncSocketSocket" Show


mistretzu
April 2nd, 2003, 09:47 AM
I made a nt service server useing MFC CAsyncSocket. I compiled the server with "Use MFC in a Shared Library" option and it works with no problems in Debug and Release.

I compiled it with "Use MFC in a Static Library" option and it crashes in both Debug and Release. In debug mode i managed to trace were it crashes. It goes like this:
CAsyncSocket::Create() -> CAsyncSocket::Socket() -> CAsyncSocket::AttachHandle() -> CAsyncSocket::LookupHandle()

the last looks like this:

CAsyncSocket* PASCAL CAsyncSocket::LookupHandle(SOCKET hSocket, BOOL bDead)
{
CAsyncSocket* pSocket;
_AFX_SOCK_THREAD_STATE* pState = _afxSockThreadState;
if (!bDead)
{
pSocket = (CAsyncSocket*)pState->m_pmapSocketHandle->GetValueAt((void*)hSocket); // the problem is on this line
if (pSocket != NULL)
return pSocket;
}
else
{
pSocket = (CAsyncSocket*)
pState->m_pmapDeadSockets->GetValueAt((void*)hSocket);
if (pSocket != NULL)
return pSocket;
}
return NULL;
}


The problem is that the member pState->m_pmapSocketHandle is NULL. WHY? Any experts in the area to tell me what i have done wrong?
I have VC.NET service pack 2 on Windows 2k.