File Transfers  
 

SocketTools includes two components which are primarily used for uploading and downloading files. The File Transfer Protocol (FTP) control is used to transfer files between the local system and an FTP server on a server. This control also enables an application to list directories and search for files, perform remote file management tasks such as renaming and deleting files, as well as a number of other functions. The Hypertext Transfer Protocol (HTTP) control can also be used to transfer files, and the properties, methods and events for the two controls are very similar.

A common question asked by most developers is which is the best protocol to use if you want to transfer files. This depends on a number of factors, including the type of server being connected to and what the program needs to do. As a general rule, FTP is a more complex protocol which offers more features in terms of the ability to manage files on a server. For example, you can use FTP to list all of the files in a directory on the server, search for those files which were modified after a certain date and download them. HTTP doesn't provide those kinds of facilities. However, FTP can present problems when it is used behind a firewall or a router which uses Network Address Translation (NAT) and applications which use FTP need to give users the ability to configure various options, such as whether or not passive-mode file transfers are used.

On the other hand, HTTP offers a much simpler protocol and typically does not have the same kinds of problems when used from behind a firewall or NAT router. However, it does not have many of the more advanced file management features that FTP supports, and the ability to upload or delete files usually requires that the administrator of the web server make specific changes to allow this.

Here are some general guidelines you can follow to determine which is the best protocol to use in a given situation:

  • If your program only downloads files from the server to the local system, use HTTP whenever possible.
     
  • If your program only uploads files from the local system to the server, use FTP whenever possible. If you must use HTTP, make sure that your web administrator has enabled the use of the PUT command.
     
  • If your program frequently downloads files from the server and occasionally uploads files, use HTTP whenever possible and make sure that your web administrator has enabled the use of the PUT command.
     
  • If your program must perform file management functions such as deleting and renaming files, creating directories or searching for files which meet a specific criteria, use FTP whenever possible.
     
  • If you want to use a secure, encrypted connection to protect the contents of the data being transferred, use HTTP whenever possible. Although there are extensions to FTP which support secure connections, those servers are not as common as secure web servers.
     
  • For broadest compatibility, use both the FTP and HTTP controls and allow your user to select which protocol to use and the various options that are available.

If you decide to use the FTP control, make sure that you set the Passive property to True. This will force the control to only establish outbound connections to the server and ensures a broader range of compatibility with various firewall and router configurations.