Click to See Complete Forum and Search --> : Multiple sockets


srikbond
December 6th, 2004, 11:25 PM
Hi,
I have developed an application using an overridden CAsyncSocket class to acquire data from a server. Now I need to get data from more than a single server. If I use multiple sockets for the client, I don't know how to distinguish which socket's OnConnect( ), OnSend( ) etc events are called. Is there some kind of way to identify the individual sockets? I tried adding an id datamember to the derived class and initialise it whenever I create and connect a new socket. But I still dont know how to retrieve its value in the OnConnect( ) etc as they seem to be event handlers and use if the "this" pointer doesn't work as they aren't member functions.

Any insight ?

MikeAThon
December 7th, 2004, 04:32 PM
.... But I still dont know how to retrieve its value in the OnConnect( ) etc as they seem to be event handlers and use if the "this" pointer doesn't work as they aren't member functions....
I'm not really certain that I understand your question. In fact, the OnXxxx functions like OnSend and OnConnect are indeed member functions for which the "this" pointer should serve to distinguish one object from another.

Could you try explaining your question in a different way?

Mike

srikbond
December 10th, 2004, 02:23 AM
Hi Mike,
Sorry my mistake. I meant to say that those On..() are called explicitly by the framework to notify the respective events.
I use 2 sockets in my client application to connect to 2 servers. I am able to send data from them to the servers requesting for responses.
At the servers, I am able to receive the requests and I reply with whatever data is requested.
Now comes my problem. At the client side, OnReceive() , I either keep getting a failed assertion or nothing. I use my own class MySocket derived from CAsyncSocket and declare objects of MySocket in the doc file of the app. And which socket object to use for the Receive function inside OnReceive() ?

NoHero
December 10th, 2004, 04:55 AM
You should post code. Reading code and finding small mistakes is a lot easier than to "read" out the mistake by our explanations.

srikbond
December 12th, 2004, 10:17 PM
Hi,
I have attached a sample application which is a part of my actual application. In this app, OnReceive never seems to get called on the client side. I run a sample app on the server which sends back the system time at the server.
This is similar to the scenario of my actual app.