I'm programming an embedded software in C (not C++) that allows me to transfer a file to the ftp (some readings that a specific hardware does), but it seems I don't know how to do the transfer. This is my code:
///pasive connection FTP
if(strncmp(szBuf , "227", 3) != 0)
sprintf(szBuf, "STOR m4.html\r\n");//command that allows storage of a file in the FTP
The thing is that STOR uses the filename, but since it is custom hardware I need a way to stream the bytes from a specific address in the SDRAM (
0x000-0xFFF for example), so I was wondering if someone could give me a little advice creating the file, fill with the information in the FTP?
Best How To :
The FTP protocol works with two distinct connections, the control connection and the data connection. Depending on the mode, the data connection may be initiated by either the server (active) or client (passive).
PASV command's (which indicates passive transfers) response contains the IP address and PORT the server is listening for data connections.
STOR command indicates to the server which filename must it use to store the data sent by the client through the data connection.
So, what you are missing here is:
- Parsing the
- Opening the data connection and sending data over it
There are other exchages between client and server, for instance to coordinate the termination of the data connection after the transfer. The protocol is described in RFC 959.
Without knowing what library you are using it's hard to say how it has to be implemented.
A step by step overview can be found here