|
-
January 21st, 2004, 07:20 AM
#1
Recieving data from an http connection
Hi
How can i recieve a data stream/file from an http connection ?
this is my connection, is there a function i need to read in the data ?
Code:
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
INTERNET_PORT nPort;
CString strErrorCode,strObject;
DWORD dwServiceType = AFX_INET_SERVICE_HTTP;
CInternetSession Session(_T("HTTPDialog"),1,dwAccessType,NULL,NULL,0);
pServer = Session.GetHttpConnection(strServer,nPort);
thanks
P
-
January 21st, 2004, 07:56 AM
#2
MSDN has a very nice sample which shows how to do what you are looking for. take a little time out. I really dont remember where it is. most prolly in Chttpconnection's samples.
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
-
January 21st, 2004, 07:58 AM
#3
I will have a look, thanks
But if anyone can remember exactly what function that would be good
Thanks
-
January 21st, 2004, 08:06 AM
#4
Nope sorry !
i have had a look through the msdn and the TEAR example, only shows you how to send a message to an http server and then process the response
Not recieve a message/data from an http connection that is contacting you, trying to give you the data.
I can open the connection but my problem is how to recieve the message being sent to me ....
Anybody got any ideas ?
P
-
January 21st, 2004, 08:14 AM
#5
after you get the http connection do the following:
Code:
CHttpFile * pHttpFile = NULL;
// do request
pHttpFile = pHttpConnection->OpenRequest(
CHttpConnection::HTTP_VERB_GET,
sPage // pagename
);
if(pHttpFile == NULL)
throw new CTestException(_T("OpenRequest()"));
// send request
fRet = pHttpFile->SendRequest();
if(!fRet)
throw new CTestException(_T("SendRequest()"));
// read, close file and delete object
pHttpFile->Read(szPageBuffer, uiBUFSIZE);
// cleanup file
pHttpFile->Close();
delete pHttpFile;
// cleanup connection
pHttpConnection->Close();
delete pHttpConnection;
// cleanup session
pInetSession->Close();
delete pInetSession;
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
|