Udostępnij za pośrednictwem


CInternetSession::GetHttpConnection

Call this member function to establish an HTTP connection and get a pointer to a CHttpConnection object.

CHttpConnection* GetHttpConnection( 
   LPCTSTR pstrServer, 
   INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER, 
   LPCTSTR pstrUserName = NULL, 
   LPCTSTR pstrPassword = NULL  
); 
CHttpConnection* GetHttpConnection( 
   LPCTSTR pstrServer, 
   DWORD dwFlags, 
   INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER, 
   LPCTSTR pstrUserName = NULL, 
   LPCTSTR pstrPassword = NULL  
);

Parameters

  • pstrServer
    A pointer to a string containing the HTTP server name.

  • nPort
    A number that identifies the TCP/IP port to use on the server.

  • pstrUserName
    A pointer to a string containing the user name.

  • pstrPassword
    A pointer to a string containing the access password.

  • dwflags
    Any combination of the INTERNET_ FLAG_* flags. See the table in the Remarks section of CHttpConnection::OpenRequest for a description of dwFlags values.

Return Value

A pointer to a CHttpConnection object. If the call fails, determine the cause of the failure by examining the thrown CInternetException object.

Remarks

GetHttpConnection connects to an HTTP server, and creates and returns a pointer to a CHttpConnection object. It does not perform any specific operation on the server. If you intend to query an HTTP header, for example, you must perform this operation as a separate step. See the classes CHttpConnection and CHttpFile for information about operations you can perform by using a connection to an HTTP server. For information about browsing an HTTP site, see the member function OpenURL. See the article Internet Programming with WinInet for steps in performing common HTTP connection tasks.

Exceptions

This method can throw exceptions of type CInternetException*.

Requirements

Header: afxinet.h

See Also

Reference

CInternetSession Class

Hierarchy Chart

CHttpConnection Class

CInternetSession::GetGopherConnection

CInternetSession::GetFtpConnection

CInternetSession::OpenURL

Other Resources

CInternetSession Members