Original Post
I am having a problem that I can''t explain or pinpoint.
Basicly what I have going on is (MFC) a main dialog containing a client socket class within it. When the client socket connects to the server, it calls the OnConnect callback function. Now since I want the main dialog to know that the user has connected to the server, I am doing a pMainDlg->PostMessage to post a custom "WM_USERCONNECT" message to the main dialog. The main dialog message map contains: "ON_MESSAGE(WM_USERCONNECT, OnUserConnect)". The OnUserConnect function is an afx_void callback that prints the results of the connection (failure or success) to the console.
Problem is::
When I first connect and the message is posted, it works. The 2nd time I connect I get an illegal error: access violation. I tested things a lot and I found that the error occours no matter what other callback function I use to handle the WM_USERCONNECT message, which means the problem does not lie within the callback. Another interesting thing is if I change PostMessage to SendMessage, the error happens on the first connection instead of the 2nd!
Can anyone give me any insight i may be missing with the message posting thing?
Thanks!