CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Apr 2004
    Posts
    5

    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!
    Last edited by rpOliveira; April 9th, 2004 at 05:01 PM.
    Ah! Nao ser eu toda a gente e toda a parte!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured