CSocket EVC++ 3.0 problem. please help
-
Hi I have a weird problem that I cannot seem to figure out. It has to do with adding an OnReceive() event in a derived CSocket class. The problem is that even though I add the virtual function OnReceived into the derived class and call my main form the event won't fire. If I map a read buffer function (when I know there is data waiting to be received) I can the buffer, however, I am unable to get the event to fire. here is the virtual function: void MySocket::OnReceive(int nErrorCode) { if(nErrorCode == 0){ ((CSmartPDADlg*)m_pWnd)->onreceive(); //((CSmartPDADlg*)m_pWnd)->WriteLog(L"RECEIVE"); } CSocket::OnReceive(nErrorCode); } Even if I put a break in the following function, it never gets called even thought it is receiving data. The onreceive() event in the main class is as follows: void CSmartPDADlg::onreceive(){ char *buff = new char[512] ; int size = 512 ; int recd ; CString recdstr ; recd = clientSocket.Receive(buff, size ) ; //m_log.SetWindowText((LPCTSTR)"HERE"); if ( recd == SOCKET_ERROR ) { MessageBox( L"Error in receive ", NULL, MB_OK); } else { buff[recd] = NULL ; recdstr = buff ; //recdstr. WriteLog(recdstr); //GetProtocolTokens(recdstr); UpdateData ( FALSE ) ; } } If anyone has ran into the problem in having EVC++ 3.0 not firing CSocket OnReceive events please advise. Any help would be appreciated. Thanks! Thanh