CSocket receive using pointers

Hello guys,
I have recently been trying to develope a chat application.I want to use dynamic allocation with linked list for my sockets so that the user can modify the max user limit at any time.Now the problem is that the CSocket::Receive dosent seem to work with the pointer.My code is something like this..
CMysocket m_listenSocket;//the listening socket
CMySocket * temp;//the socket pointer

//In the accept or the connect functions
temp = new CMySocket;

//on accept
//or connect

Now the program compiles and executes without error.It also connects and accepts connections flawlessly.It also sends data without an error.However whten i call the onreceive the Receive function call fails and the program crashes.I cant understand as to what i might be doing wrong.Please help...


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

in the meanwhile I look up the two parameters, that you just ignore ;-)
Strange. I looked it up, the other parameters are really optional and not of interrest if you don't want to know the client that sent the request emidiately.
Tell me something about "onreceive"
If evereything else works, it's very likely, that something happens before you call temp->Receive.
e.g. how does the temp pointer finds is way into the onreceive function is it a global variable and so on...

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

the_voidAuthor Commented:
hello leo,
I need to dereference the socket pointer to get to the memory.It dosent compile otherwise.Anyways, it connects perfectly.I actually tried it with another instance of the program wherein i was using an array of socket pointers.I could send data from this application and receive it without problems at the other end.This program however fails to accept any data.
Temp is global in the main dlg.I do not call temp->receive cause i need to accept data from all the sockets.I just use Receive().This works with an array of sockets.I also tried to specify the socket as in socket->receive() abandoning the whole multiple user idea but even that failed with pointers.
Any help will be greatly appreciated...

also... i do use the sockaddr struct in  my program..i just didnt use it in the example above.

the_voidAuthor Commented:
thanks a lot guys, but i figured it out

i needed to use the this pointer with the recieve as in
this->Receive() instead of just Receive() that i used with arrays.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I apreciate, that you found it yourself. Other people seems to stop thinking as soon, as they made the post... ;-).
I use the api functions, so I don't have to deal with this and the program get's much smaller ;-).
If I have the joice between class and not I always think if I have benefits of the class. And if not, like in this case where the class just reassambles the api and I don't benefit from the class at all, I choose not to use MFC.

This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.