Design Article
Guide to Embedded Systems Architecture - Part 4: Application layer networking protocol examples
Tammy Noergaard
5/10/2010 2:00 PM EDT
The following pseudocode demonstrates a possible initial FTP connection mechanism within an FTP client application in which access control commands are transmitted to an FTP site.
|
FTP Client Pseudocode for access control commands USER and PASS
FTPConnect (string host, string login, string password) {
TCPSocket s= new TCPSocket(FTPServer,21); // establishing a TCP connection to port 21 of the destination device
Timeout = 3 seconds; // timeout for establishing connection 3 seconds
If response from recipient then {
// reply 230 means user logged in, to proceed FTP Successful = TRUE; } }
else { |
In fact, as shown in the pseudocode below, the FTP client needs to provide mechanisms that support the user being able to transmit the different types of commands (shown in Table 10-10) available via FTP, as well as process any response codes received (shown in Table 10-9).
|
FTP Client Pseudocode
// "QUIT" access command routine
transmit to server ("QUIT");
// reply 221 means server closing control connection
// FTP Service Command Routines
// "DELE"
transmit to server ("DELE " + filename);
// reply 250 means requested file action Ok
// "RNFR"
// reply 350 means requested file action pending further information
transmit to server ("RNTO " + newfilename);
// reply 250 means requested file action Ok
........ |
The FTP Server initiates the data connection and any transfers according to the commands specified by the FTP client.

