For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
Manages your connection to an Internet server.
class CInternetConnection : public CObject
|CInternetConnection::CInternetConnection||Constructs a |
|CInternetConnection::GetContext||Gets the context ID for this connection object.|
|CInternetConnection::GetServerName||Gets the name of the server associated with the connection.|
|CInternetConnection::GetSession||Gets a pointer to the CInternetSession object associated with the connection.|
|CInternetConnection::operator HINTERNET||A handle to an Internet session.|
It is the base class for MFC classes CFtpConnection, CHttpConnection, and CGopherConnection. Each of these classes provides additional functionality for communicating with the respective FTP, HTTP, or gopher server.
To communicate directly with an Internet server, you must have a CInternetSession object and a
To learn more about how the WinInet classes work, see the article Internet Programming with WinInet.
This member function is called when a
CInternetConnection object is created.
CInternetConnection( CInternetSession* pSession, LPCTSTR pstrServer, INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER, DWORD_PTR dwContext = 1);
A pointer to a CInternetSession object.
A pointer to a string containing the server name.
The number that identifies the Internet port for this connection.
The context identifier for the
CInternetConnection object. See Remarks for more information about
You never call
CInternetConnection yourself; instead, call the CInternetSession member function for the type of connection you want to establish:
The default value for
dwContext is sent by MFC to the
CInternetConnection-derived object from the CInternetSession object that created the InternetConnection-derived object. The default is set to 1; however, you can explicitly assign a specific context identifier in the CInternetSession constructor for the connection. The object and any work it does will be associated with that context ID. The context identifier is returned to CInternetSession::OnStatusCallback to provide status on the object with which it is identified. See the article Internet First Steps: WinInet for more information about the context identifier.
Call this member function to get the context ID for this session.
DWORD_PTR GetContext() const;
The application-assigned context ID.
The context ID is originally specified in CInternetSession and propagates to
CInternetConnection- and CInternetFile-derived classes, unless specified differently in the call to a function that opens the connection. The context ID is associated with any operation of the given object and identifies the operation's status information returned by CInternetSession::OnStatusCallback.
For more information about how GetContext works with other WinInet classes to give the user status information, see the article Internet First Steps: WinInet for more information about the context identifier.
Call this member function to get the name of the server associated with this Internet connection.
CString GetServerName() const;
The name of the server this connection object is working with.
Call this member function to get a pointer to the
CInternetSession object that's associated with this connection.
CInternetSession* GetSession() const;
A pointer to a CInternetSession object associated with this Internet connection object.
Use this operator to get the API-level handle for the current Internet session.
operator HINTERNET() const;