I am working in a visual c++ voice chat application (dialog based application). I am using the CAsychsocket Class for the TCP/IP connection. i have a full duplex sound card but i cann't send and receive at the same time. If i send from one PC to anther i received the voice well but the application is hanging so that i can just send in one direction. I need a simple code example to till me how to make the sending and receiving in different threads. I read a lot of articles in that issue but i cann't understand. Could you please help me.
According to your problem you need 2 threads for your socket communication.
One thead to process your incomming data and second to send .
Create a class derived from CWinThread and make 2 functions in it 1: Send Data 2: ReceiveData.
When u create a connected socket or accepted socket then create 2 objects of this thread class and set their pointer in socket class .
When u Receive any data then post a message to one of your thread class to receive and process data (ReceiveData function).
Thank you very much for your help. that was realy great.
I create a class derived from CWinThread called it CMyData then i make two member functions of that class (SendData() and ReceiveData()) the two functions are void and public. Then i create two member variables of the CMyData class called them m_pRecord, and m_pPlay . I already have a class derived from CAsyncSocket which is CMySocket. Is that OK!!!
I just need to know how can i "create 2 objects of this thread class and set their pointer in socket class".
Last edited by ashraf_diaa; September 21st, 2004 at 02:37 PM.
Thank you very much for your help. I am now have three classes which are CSockDlg, CMySocket, CMyData. I am sorry but i realy confused. I don't know how to connect these three sockets correctly. I always have problems with pointers.
Could you please advice me what is the easiest way to make these three classes working correctly. when they are just two i can make them connected correctly but now when they are three the situation get more complex. (if you don't mind and have time to help me i can send you the source code of my program, it is already working but just sending from on side to another)
Thank you very much.
Last edited by ashraf_diaa; September 23rd, 2004 at 07:49 AM.