-
March 6th, 2004, 01:24 PM
#1
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);
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??
-
March 6th, 2004, 01:31 PM
#2
maybe..
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.
1. Search in MSDN
2. Search in Google
3. Search in CodeGuru.com
4. Ask in the forum
ABNM.....asih b*&6 nahi mardeh
-
March 6th, 2004, 01:37 PM
#3
Thank you for your help. But I want to use socket to have a try. I wonder why this problem occurs.
-
March 6th, 2004, 02:47 PM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|