Muokkaa

Jaa


Prerequisites for Internet Client Classes

Some actions taken by an Internet client (reading a file, for example) have prerequisite actions (in this case, establishing an Internet connection). The following tables list the prerequisites for some client actions.

General Internet URL (FTP, Gopher, or HTTP)

Action Prerequisite
Establish a connection. Create a CInternetSession to establish the basis of an Internet client application.
Open a URL. Establish a connection. Call CInternetSession::OpenURL. The OpenURL function returns a read-only resource object.
Read URL data. Open the URL. Call CInternetFile::Read.
Set an Internet option. Establish a connection. Call CInternetSession::SetOption.
Set a function to be called with status information. Establish a connection. Call CInternetSession::EnableStatusCallback. Override CInternetSession::OnStatusCallback to handle calls.

FTP

Action Prerequisite
Establish an FTP connection. Create a CInternetSession as the basis of this Internet client application. Call CInternetSession::GetFtpConnection to create a CFtpConnection object.
Find the first resource. Establish an FTP connection. Create a CFtpFileFind object. Call CFtpFileFind::FindFile.
Enumerate all available resources. Find the first file. Call CFtpFileFind::FindNextFile until it returns FALSE.
Open an FTP file. Establish an FTP connection. Call CFtpConnection::OpenFile to create and open a CInternetFile object.
Read an FTP file. Open an FTP file with read access. Call CInternetFile::Read.
Write to an FTP file. Open an FTP file with write access. Call CInternetFile::Write.
Change the client's directory on the server. Establish an FTP connection. Call CFtpConnection::SetCurrentDirectory.
Retrieve the client's current directory on the server. Establish an FTP connection. Call CFtpConnection::GetCurrentDirectory.

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.

Gopher

Action Prerequisite
Establish a gopher connection. Create a CInternetSession as the basis of this Internet client application. Call CInternetSession::GetGopherConnection to create a CGopherConnection.
Find the first file in the current directory. Establish a gopher connection. Create a CGopherFileFind object. Call CGopherConnection::CreateLocator to create a CGopherLocator object. Pass the locator to CGopherFileFind::FindFile. Call CGopherFileFind::GetLocator to get the locator of a file if you need it later.
Enumerate all available files. Find the first file. Call CGopherFileFind::FindNextFile until it returns FALSE.
Open a gopher file. Establish a gopher connection. Create a gopher locator with CGopherConnection::CreateLocator or find a locator with CGopherFileFind::GetLocator. Call CGopherConnection::OpenFile.
Read a gopher file. Open a gopher file. Use CGopherFile.

See also

Win32 Internet Extensions (WinInet)
MFC Classes for Creating Internet Client Applications
Writing an Internet Client Application Using MFC WinInet Classes