A problem seems to happen in the client program in the Connect() function, and all of its parameters have been set up correctly... After the client receives the DPN_MSGID_CONNECT_COMPLETE message. I know that the error occurs before the Connect() function completes, because immediately after the function, I have debug output. I set an event to show when the connection has been completed, and it relies on the WM_TIMER message.
case DPN_MSGID_CONNECT_COMPLETE: #ifdef RENDER_DEBUG MessageBox( 0, "DirectPlayMessageHandler: DPN_MSGID_CONNECT_COMPLETE", "Client Message", 0 ); #endif PDPNMSG_CONNECT_COMPLETE pConnectCompleteMsg; pConnectCompleteMsg = (PDPNMSG_CONNECT_COMPLETE)pMsgBuffer; MessageBox( 0, "ENTER CRITSECTION - DirectPlayMessageHandler: DPN_MSGID_CONNECT_COMPLETE", "Client Message", 0 ); // An error is caused here unless the following line is commented // I'm not sure why this occurs, because this critical section can be used without // errors in other cases. EnterCriticalSection( &g_csMessageSection ); MessageBox( 0, "DONE CRITSECTION - DirectPlayMessageHandler: DPN_MSGID_CONNECT_COMPLETE", "Client Message", 0 ); //#ifdef RENDER_DEBUG MessageBox( 0, "DirectPlayMessageHandler: DPN_MSGID_CONNECT_COMPLETE", "Client Message", 0 ); //#endif g_hrConnectComplete = pConnectCompleteMsg->hResultCode; SetEvent( g_hConnectCompleteEvent ); //#ifdef RENDER_DEBUG MessageBox( 0, "g_hConnectCompleteEvent set", "Client Message", 0 ); //#endif LeaveCriticalSection( &g_csMessageSection ); //#ifdef RENDER_DEBUG MessageBox( 0, "DirectPlayMessageHandler: DPN_MSGID_CONNECT_COMPLETE Completed", "Client Message", 0 ); //#endif break;
There isn't any important code within this function after the break at the bottom of the source code.
The final message box is shown, but an error occurs immediately after the message handler returns its value. This means it crashes before the Connect() function completes, even though it says that the connection has been completed.