Receiving Data (Sockets) - Experts Please Help....
Posted on 1999-07-12
I am building a voice chat application for which I am required to receive packets of data containing voice in a consistent manner. i.e. I have to receive each packet without any loss. The size of my voice packets is fixed which is 845 bytes. I am using threads for both sending and receiving the data. The problem is that the data reaching on destination is lost somewhere and maybe (i am not sure) the data from the next packet got appended to the previous one thus spoiling the whole packet.
Following is the code to send and receive the data. both are threads. The threads to receive the data is started in the beginning of application and works till the application is continued.
//Code to send the data
//As soon as a buffer is filled with audio the following //thread is started and is passed the audio data in the //form of one of the data member of structure PADATA
void sendAThread(PADATA tInfo)
//code to receive the data
rrc = recv(remote_socket,(char*)(&(buffer[tb])), nsize,0); if(rrc>0)
//Process the bufer
Will it help if insted of sending the buffer, first i put into a structure and then pass it to the socket on other side.
As far as LAN is concerned the application is running fine on that.