File Transfer Protocol (FTP) is a standard network protocol used to copy a file from one host to another over a TCP-based network, such as the Internet. FTP is built on a client-server architecture and utilizes separate control and data connections between the client and server. FTP users may authenticate themselves using a clear-text sign-in protocol but can connect anonymously if the server is configured to allow it.
Another popular method for transferring files over the Internet is the File Transfer Protocol (FTP). Unlike HTTP, an application that uses FTP will typically connect to a server and remain connected while it transfers multiple files back and forth. Even though the last few years have seen a significant number of file transfer operations moving toward using HTTP and GET requests, FTP still remains a popular protocol, as it provides good access control and a reliable file transfer mechanism. Pocket PC supports FTP through many of the same WinInet API functions you have already seen (such as InternetReadFile()), with the addition of a few FTP-specific commands.
![MainImg](MainImg.gif)
FTP is unlike other protocols we've seen so far in that it actually uses two TCP connections to communicate to the server and transfer files. The first connection, which is known as the control connection, is established when a client connects to an FTP server (its well-known port is 21). Once you have connected, the client application uses the control connection to communicate back and forth with the FTP server, sending commands and receiving responses much in the same way HTTP does. This may include operations such as navigating directories and removing files.
Once the client finds a file to transfer, you need to establish your second connection, which is known as the data connection. The data connection is unlike others you've seen so far, the server initiates the connection by contacting the client on a specified port. This happens when a client sends the server the PORT command (which contains the client's IP address and an available port), which is followed by the actual file request (using the RETR command). Once a connection from the server to the client has been accepted, the server transfers the file to the client. Once the transfer is complete, the data connection is closed; however, the control connection remains active throughout the process until you disconnect from the FTP server or a timeout occurs.
This application is a ftp client, tested on the Pocket PC 2003 emulator and on the OMAP 3530 EVM main board. The library used for the ftp function is WinInet. The example showed in the source code that can be downloaded from the link existing below, connects to a ftp server (e.g. “ep.etc.tuiasi.to” using the user-name ”student” and password “student”), list all the files inside and also someone can download any file selected. |