Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSocket/CAsyncSocket problems

Status
Not open for further replies.

Valius

Programmer
Oct 20, 2000
174
US
I'm attempting to derive a class from CSocket/CAsyncSocket (preferably CSocket) so that I can override the OnReceive function. For some reason, my OnReceive override NEVER gets called. It's getting VERY frustrating. Here is the basic stuff that I have....


my soc.h file
class MySocket : public CAsyncSocket
{
public:
CAsyncSocket *Socket;
virtual void OnReceive(int nError);
};


my .cpp file

#include "soc.h"
void MySocket::OnReceive(int nError);
{
//Do something here
CAsyncSocket::OnReceive(nError);
}

It seems that this would give me control of the OnReceive funtion...but it never works! Can someone PLEASE help me in this subject before I take a bat to my computer! Thanks in advance!

Niky Williams
 
Are you using it on the same computer or from different computers? John Fill
1c.bmp


ivfmd@mail.md
 
Same computer, I'm setting up a client and server on the same computer using the loopback address. I've been able to send messages between the two programs, but to make it more versitle, I wanted to be able to use OnReceive()....plus, I think it would also make it a bit easier too.

Thanks for your time.

Niky Williams
 
Oh, I feel stupid. I think I found the problem. When I was declaring my variables, I was making them of type CAsyncSocket....I changed this so that my variables had a declaration of my class instead of the base class. When I did this, my functions were called instead of the non overridden functions.....does this sound correct?

Niky Williams
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top