Click to See Complete Forum and Search --> : CAsyncSocket problem


cilu
March 4th, 2004, 09:45 AM
I want to create a server/client application, based on asynchronous communication. I want to use UDP, but TCP would also do.

I wrote some code, but I have a problem. I used TCP and two classes (CServerSocket and CClientSocket) derived from CASyncSocket. Both server and client are on the same machine, but this is irrelevant. I start up the server (Create, Listen and Accept called in OnAccept), connect the client (Create, Connect). Until here everything is ok. The messages from server arrive at the client, but no message is received in server. However when I call Send in CClientSocket it returns the number of bytes of my message, so it produces no error. But on server OnReceive is never called. So, my message is sent by the client, but my server do not detect it.

Does anyone have an idea about what I do wrong?

Some working code, examples, anything would be very welcome.

Thank you.

j0nas
March 4th, 2004, 10:05 AM
You say that the OnReceive mehtod isn't called on the tcp server. Maybe you accidentally thought the listening socket's OnReceive method would be called?!?!

Sam Hobbs
March 4th, 2004, 04:20 PM
I have written only one sockets program but it can receive UDP packets. The important parts of it are in my Receiving UDP Using CAsyncSocket (http://simplesamples.info/MFC/CAsyncSocketUDPReceive.php) page. Let me know if it works for you too.

Andreas Masur
March 6th, 2004, 03:38 PM
[Moved thread]