Binary Files downloaded using Tools.h++ Professional are the Wrong Size

Article ID: 1077
Last updated: 29 Jan, 2008
Article ID: 1077
Last updated: 29 Jan, 2008
Revision: 1
Views: 3242
Posted: 19 Jul, 1999
by --
Updated: 29 Jan, 2008
by
Problem


When downloading a binary file from an FTP or HTTP server using Tools.h++ Professional, the size of the file that I receive is different from the file on the server.


Cause


The problem is caused by most systems defaulting to using ASCII as their download method, which will interpret the data, instead of sending it in it's raw form. There are three locations when this interpretation can occur.
  1. The Server. This usually occurs in the RWIFtpClient/Agent classes, in which the data is sent by default in ASCII format by some servers.

     

  2. The RWStreamCoupler class. The RWStreamCoupler class is used to redirect information on an input stream directly to an output stream (For example, from a socket to a local file.) The StreamCouple itself can be set to either interpret the data or simply pass it as is, and if it is set to interpret the data in a binary file, the resulting file may be corrupted.

     

  3. The File Stream A file stream itself can be set to either BINARY or ASCII format. If the file is opened in ASCII mode, and BINARY data is streamed to it, data corruption may occur.

     




Action


Each of the above causes has it's own solution.

The Server.

If the server is formatting the data as ASCII before sending it, then you will need to tell the server to send it as BINARY data instead.

In the RWIFtpAgent class, that can be done in the calls to put() and get(). Both of these functions have an optional third argument that designates the type of transfer that should occur. In order to force the server to send the data in binary format, you will need to pass the enum 'tmode_binary' to the get() or put() call that you are making.

 


   RWSocketPortal portal;
   RWIFtpAgent agent(

This article was:   Helpful | Not helpful
Report an issue
Article ID: 1077
Last updated: 29 Jan, 2008
Revision: 1
Views: 3242
Posted: 19 Jul, 1999 by --
Updated: 29 Jan, 2008 by

Others in this category