CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2000
    Location
    England
    Posts
    574

    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

  2. #2
    Andy Tacker is offline More than "Just Another Member"
    Join Date
    Jun 2001
    Location
    55°50' N 37°39' E
    Posts
    1,503
    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.

  3. #3
    Join Date
    May 2000
    Location
    England
    Posts
    574
    I will have a look, thanks

    But if anyone can remember exactly what function that would be good

    Thanks

  4. #4
    Join Date
    May 2000
    Location
    England
    Posts
    574
    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

  5. #5
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    49
    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
  •  





Click Here to Expand Forum to Full Width

Featured