// JP opened flex table

Click to See Complete Forum and Search --> : CSocket problem?


olin
March 6th, 2004, 01:24 PM
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);
AsyncSelect(FD_READ);
}

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

m_pSocket = new CMySocket(this);
m_pSocket->CAsyncSocket::Create()
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).

Why??

munna
March 6th, 2004, 01:31 PM
This is what you should be using, if plan to use http

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.

olin
March 6th, 2004, 01:37 PM
Thank you for your help. But I want to use socket to have a try. I wonder why this problem occurs.

Andreas Masur
March 6th, 2004, 02:47 PM
[Moved thread]

//JP added flex table