I was implementing FTP client to download file from server. I used the command in the below sequence. I could succeed in downloading the file and the connection was terminated gracefully however, the content downloaded is not the same as the content in the original file. I could see some additional [NUL] characters displayed when I open it using notepad++ and notepad displays it as space. I have to get rid of this.
Soon, I set the PASV mode, I initiate data connection. Once the data connection is established successfully, I trigger RETR command, and after getting response from server, i initiate reading data from data socket.
I am using GCC Cygwin on windows machine to execute FTP client.
Please help me out guys. Where have i gone wrong.?
**CLIENT**:
CONNECTION ESTABLISHMENT
**********************************
CONNECTING TO [abc.def.ghi.jkl]:[21]
Client connected to [abc.def.ghi.jkl] successfully..
**SERVER**:
=========
220-FileZilla Server version 0.9.41 beta
220-written by Tim Kosse (Tim.Kosse@gmx.de)
220 Please visit http://sourceforge.net/projects/filezilla/
**********************************
**CLIENT**:
=========
Sending Username: abc
FTP COMMAND: USER abc
**SERVER**:
=========
331 Password required for abc
**********************************
**CLIENT**:
=========
Sending Password: ******
FTP COMMAND: PASS ******
**SERVER**:
=========
230 Logged on
**********************************
**CLIENT**:
=========
CHANGING WORKING DIRECTORY TO [/test]
FTP COMMAND: CWD /test
**SERVER**:
=========
250 CWD successful. "/test" is current directory.
**********************************
**CLIENT**:
=========
SET TYPE-A MODE
FTP COMMAND: TYPE A
**SERVER**:
=========
200 Type set to A
**********************************
**CLIENT**:
=========
SET PASV MODE
FTP COMMAND: PASV
**SERVER**:
=========
227 Entering Passive Mode (abc,def,ghi,jkl,4,62)
**********************************
CONNECTING TO [abc.def.ghi.jkl]:[1086]
Client connected to [abc.def.ghi.jkl] successfully..
**********************************
**CLIENT**:
=========
RETRIEVE FILE: [abc.txt]
FTP COMMAND: RETR abc.txt
**SERVER**:
=========
150 Connection accepted
*******************************************
DOWNLOADING FILE..
FILE DOWNLOAD COMPLETE [D:\FTP_Client/abc.txt]
*******************************************
**SERVER**:
=========
226 Transfer OK
**********************************
**CLIENT**:
=========
LOGGING OUT..
FTP COMMAND: QUIT
**SERVER**:
=========
221 Goodbye