Using CAsyncSocket to communicate!
Hi!
I have to develop an application that communicates with a server (running on the same machine) with UDP datagrams. I started with a dialog based application and derived a class from CAsyncSocket wich I called CRoteiroSockets, in order to receive the data in the overriden OnReceive(int errorCode) function.
I can connect to the server using this code (it sends a XML message):
Code:
void CRoteiroDlg::OnBtConnect()
{
CRoteiroSockets sockRoteiro;
if (sockRoteiro.Create(0,SOCK_DGRAM, FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE) == 0)
AfxMessageBox("ceate error");
if (sockRoteiro.Connect("localhost",6000) == 0)
AfxMessageBox("connect error");
char pbuf[500];
strcpy(pbuf,"<Robot Name=\"Roteiro\" Id=\"1\"></Robot>");
sockRoteiro.Send(pbuf,500,0);
}
I know that the server receives this message and responds with other message but I never get anything in my client. The CRoteiroSockets::OnReceive(int nErrorCode) function is never executed. Anyone can explain me this? How can I receive the data sent by the server?
Thanks for your attention!