A-jage

Hello.
Code Block


I have created a new class "CMessengerSocket" which is derived from "CSocket".

The connection is build with the following code:

void CDesktopChatMessengerApp::ConnectServer()
{
//Initialization
m_NotificationServer = "messenger.hotmail.com";
m_NotificationServerPort = 1863;

//Create connection
CMessengerSocket* pMessengerSocket = new CMessengerSocket;
m_pMessengerSocket = pMessengerSocket;
m_pMessengerSocket->Create();
m_pMessengerSocket->Connect(m_NotificationServer, m_NotificationServerPort);

}


The connection is build successfully. (With "netstat" I can see the connection).
Now, the eventhandler "CMessengerSocket::OnConnect()" should be called:
The declaration:

Code Block

public:
virtual void OnConnect(int nErrorCode);




The overriden function:

Code Block

void CMessengerSocket::OnConnect(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
if(0 != nErrorCode)
{
m_ConnectionFailed.LoadString(IDS_CONNECTION_FAILED);
AfxMessageBox(m_ConnectionFailed);
}
else
{
//Call NewFrame() to create new mainframe
theApp.NewFrame();
}

CSocket::OnConnect(nErrorCode);
}




But I don't know why, the eventhandler isn't executed. There is no error while building.

A-jage




Re: Visual C++ Language Eventhandler is'n executed

Andreas Masur

Well....it is hard to tell without seeing your socket class...nonetheless, I would recommend deriving from 'CAsyncSocket' rather than 'CSocket'....