You should probably use a library for this and not reinvent the wheel which library will be used on your platform. Is there a reason you need to use C rather than a higher level language, or just want the exercise to learn about socket programming with C?
Others recommended libCurl , it is also implemented in heaps of other languages. I would add ftplib and libftp (currently stopped) in this list. All of them are FOSS so good for studying.
source share