CAysncSocket Notifications
-
Hi, I have a CAsyncSocket which is a member of a CWinThread class. The notifications however m OnSend, OnReceive seem to go the Main Thread. Do I need a Window or does the thread CWinThread ( a UI thread ) have to have the CDialog which is using CWinThread have it s m_pMainWnd point to a CDialog to get the notifications sent to that CWinThread Thanks
-
Hi, I have a CAsyncSocket which is a member of a CWinThread class. The notifications however m OnSend, OnReceive seem to go the Main Thread. Do I need a Window or does the thread CWinThread ( a UI thread ) have to have the CDialog which is using CWinThread have it s m_pMainWnd point to a CDialog to get the notifications sent to that CWinThread Thanks
1. MFC class CWinThread does not have a member of the CAsyncSocket type. Perhaps, you meant that you created a CWinThread derived class which contain a CAsyncSocket derived object? 2. To handle CAsyncSocket notifications you have to override the CAsyncSocket::OnSend, CAsyncSocket::OnReceive and probably other virtual methods. See MSDN article Windows Sockets: Socket Notifications[^]
-
1. MFC class CWinThread does not have a member of the CAsyncSocket type. Perhaps, you meant that you created a CWinThread derived class which contain a CAsyncSocket derived object? 2. To handle CAsyncSocket notifications you have to override the CAsyncSocket::OnSend, CAsyncSocket::OnReceive and probably other virtual methods. See MSDN article Windows Sockets: Socket Notifications[^]
-
CAsyncSocket is a member of my CWinThread Joe Newcomber informed that if I declared the CAsynsocket on the stack instead of the heap I will get notification thru the main thread Thanks
> Joe Newcomber informed that if I declared the CAsynsocket on the stack instead of the heap I will get notification thru the main thread :zzz: Well where and how did Joe inform you about it?
-
> Joe Newcomber informed that if I declared the CAsynsocket on the stack instead of the heap I will get notification thru the main thread :zzz: Well where and how did Joe inform you about it?
I sent him a e-mail earlier about the problem my workaround was to save the threadid before doing the connect After getting the notification I did a PostThread to the Thread did the connect Joe said that the reason this Happened (getting the notification to the Main Thread) Because I had declared my CAsynSocket Class on the Stack e.g. CAsynSocket mysocket. As opposed to the heap CAsynSocket *mysocket I haven't tried this out yet
-
I sent him a e-mail earlier about the problem my workaround was to save the threadid before doing the connect After getting the notification I did a PostThread to the Thread did the connect Joe said that the reason this Happened (getting the notification to the Main Thread) Because I had declared my CAsynSocket Class on the Stack e.g. CAsynSocket mysocket. As opposed to the heap CAsynSocket *mysocket I haven't tried this out yet
Your retelling of the Joe's reply is a little vague... But did you read his essays Detach[^] and KB192570: MFC Asynchronous Ports[^]?