----- Original Message -----
> From: Gies,Brad
> Sent: 7/6/2006 11:35:48 AM
> To: twsocket@elists.org
> Subject: Re: [twsocket] FTP missing bytes
> It seems the answer is that I now have to send the Type command before I
> do the PUT. Did it used to default to binary before, and now it defaults
> to ASCII? 

Your FTP server has probably changed to a UNIX-type environment; or if it was 
always UNIX, the default transfer mode has been changed.  What happened to the 
file is that it is being transmitted in ASCII mode, and a couple of bytes have 
been removed when newline translations were wrongly executed.  This will only 
be a problem when transfering between heterogenous environments with differing 
newline sequences (e.g. from Windows to UNIX, or from UNIX to Windows).  Why?


1. Windows uses a CRLF (#13#10) pair for line-ends
2. While UNIX uses only the LF (#10) character for line-ends
2. Your file, even while being binary, probably contains a contiguous pair of 
bytes with the sequence #13#10 in it
3. These 2-byte sequences are being (wrongly) translated to the UNIX newline 
character #10, and a byte is being removed.

If two of these sequences exist in your file, that will cause two bytes to be 
removed.  Since the file is binary, this in essence corrupts it.

As others have mentioned, the best way to avoid this is to *always* call 
SetType before transmitting and never assume that the server will default to 
the correct type.


To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to