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

Thread: CAsyncSocket

  1. #1
    Guest

    CAsyncSocket

    //////////////////////////////////////////////////////
    // Help me !
    //
    // I am makeing a sync communication by using TCP/IP
    // Following is the code and programming sequence
    ///////////////////////////////////////////////////////
    // IPADRESS :203.248.101.130
    // PORT ADDRESS : 7
    // above is echo server at our company , and I checked that
    // echo server received data and responsed it
    //
    // some of telnet program send data and get the response
    // but my program sended data but got no response
    //
    // as you can see the my code sequence, I don't want to use
    // OnReceive() function supported CAsyncSocket class at MFC
    // just want to use Receive function as soon as sending data
    //
    // I want drive a class from CAsyncSocket class in MFC
    /////////////////////////////////////////////////////////////
    //
    // Code Sequency
    //
    // send data 1
    // client -----------------------------> host
    // <----------------------------
    // response
    //
    // send data #2
    // client -----------------------------> host
    // <----------------------------
    // response
    //
    //////////////////////////////////////////////////////
    //
    // summary of code
    //
    // m_Sock.send ("data 1",strlen(data 1");
    // m_Sock.receive(&strPtr,100);
    // if(strcmp("strPtr","ACK") <> 0)
    // {
    // m_Sock.close();
    // retuen FALSE;
    // }
    //
    // m_Sock.send ("data 2",strlen(data 1");
    // m_Sock.receive(&strPtr,100);
    // if(strcmp("strPtr","ACK") <> 0)
    // {
    // m_Sock.close();
    // retuen FALSE;
    // }
    // return TRUE;
    ////////////////////////////////////////////////////////
    // Following is my code at my program.

    char strTmp[100];
    BOOL bRes;
    char cValue =0;


    bRes = m_Sock.Create();
    bRes = m_Sock.SetSockOpt(TCP_NODELAY,&cValue,1,IPPROTO_TCP);
    bRes = m_Sock.SetSockOpt(
    bRes = m_Sock.Connect("203.248.101.130",7);

    m_Sock.SendMessage("aaaa"); // send data
    * m_Sock.Send(strTmp,strlen(strTmp));

    memset(&strTmp,0x00,sizeof(strTmp));
    * m_syncSock.Receive(strTmp,strlen(strTmp)); // read data from sock
    AfxMessageBox(strTmp); // here I wnat to see the data
    }

    ///////////////////////////////////////////////
    // 1) Here I wonder if is is possible or not,
    // 2) Is any setting is wrong ?
    // 3) Is there other solutions for this problem?
    //
    // PS : Rapid response is highly appreciated.
    /////////////////////////////////////////////


  2. #2
    Join Date
    Apr 1999
    Location
    Canada
    Posts
    12

    Re: CAsyncSocket

    Why don't you use the CSocket class ? If you don't need asynchronous operations you should use CSocket.


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