How to send/receive binary data through sockets?

view full story

http://stackoverflow.com – I have to code a FTP server and I have a problem on how data is transferred. I'm using ftp command on linux to test it and I'm currently working on LIST, which sends the list of files/directories in the working directory. Everything works fine (ftp well prints the list of files) except that ftp prints the following warning: WARNING! 5 bare linefeeds received in ASCII mode File may not have transferred correctly. I would like to remove that warning, I think ftp is expecting binary data but I don't know how to send data like that through socket, I'm currently doing the most basic way to send (HowTos)