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

Thread: CSocket problem?

  1. #1
    Join Date
    Feb 2004

    CSocket problem?

    I want to use socket to send and receive data with a website.
    I created my own CMySocket derived from CSocket, and overrided the OnSend and OnReceive methods:

    void CMySocket::OnReceive(int nErrorCode)
    char strRecv[1024];
    Receive(strRecv, 1024);

    void CClickSocket::OnSend(int nErrorCode)
    Send("Get", 3);

    then I used the this socket in one of document member function:

    m_pSocket = new CMySocket(this);
    m_pSocket->Connect(szIP, 80)

    But when I ran program, only the OnSend function executed. The OnReceive function doesn't run at all (I've set a break to check it).


  2. #2
    Join Date
    Jul 1999
    San Jose,CA


    This is what you should be using, if plan to use http


    Action Prerequisite
    Establish an HTTP connection.
    Create a CInternetSession as the basis of this Internet client application.
    Call CInternetSession::
    GetHttpConnection to create a CHttpConnection object.

    Open an HTTP file. Establish an HTTP connection.
    Call CHttpConnection::OpenRequest to create a CHttpFile object.
    Call CHttpFile::AddRequestHeaders.
    Call CHttpFile::SendRequest.
    Read an HTTP file. Open an HTTP file.
    Call CInternetFile::Read.
    Get information about an HTTP request. Establish an HTTP connection.
    Call CHttpConnection::OpenRequest to create a CHttpFile object.
    Call CHttpFile::QueryInfo.
    1. Search in MSDN
    2. Search in Google
    3. Search in CodeGuru.com
    4. Ask in the forum

    ABNM.....asih b*&6 nahi mardeh

  3. #3
    Join Date
    Feb 2004
    Thank you for your help. But I want to use socket to have a try. I wonder why this problem occurs.

  4. #4
    Join Date
    May 2000
    KY, USA
    [Moved thread]
    Ciao, Andreas

    "Software is like sex, it's better when it's free." - Linus Torvalds

    Article(s): Allocators (STL) Function Objects (STL)

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a Codeguru.com survey!

HTML5 Development Center