Embedded FTP Client


Topics:

Overview
Data Members
Functions


Overview

The embedded FTP (File Transfer Protocol) client is a cross platform FTP implementation used with applications that require FTP client/server functions. The gxsFTPClient class is derived from the gxSocket class and conforms to RFC 959: http://www.faqs.org/rfcs/rfc959.html


Public Data Members

gxSocket gxsFTPClient::ftp_data - Socket used to transfer data to this client.

int gxsFTPClient::ftp_data_port - FTP data port client is listening on.

char gxsFTPClient::reply_buf[gxsBUF_SIZE] - Buffer used to hold the last reply.

char gxsFTPClient::command_buf[gxsBUF_SIZE] - Buffer used to hold the last command.

int gxsFTPClient::time_out_sec - Number of seconds before a blocking timeout.

int gxsFTPClient::time_out_usec - Number of microseconds before a blocking timeout.


Functions

gxsFTPClient::gxsFTPClient()
gxsFTPClient::~gxsFTPClient()
gxsFTPClient::CloseDataPort()
gxsFTPClient::ConnectClient()
gxsFTPClient::FTPChDir()
gxsFTPClient::FTPDelete()
gxsFTPClient::FTPGet()
gxsFTPClient::FTPImageType()
gxsFTPClient::FTPList()
gxsFTPClient::FTPLogin()
gxsFTPClient::FTPLogout()
gxsFTPClient::FTPMkDir()
gxsFTPClient::FTPMove()
gxsFTPClient::FTPPWD()
gxsFTPClient::FTPPut()
gxsFTPClient::FTPRmDir()
gxsFTPClient::FTPSize()
gxsFTPClient::FTPStat()
gxsFTPClient::OpenDataPort()
gxsFTPClient::ReadDataPort()
gxsFTPClient::RecvResponse()
gxsFTPClient::SendCommand()
gxsFTPClient::SetTimeOut()
gxsFTPClient::WaitForReply()
gxsFTPClient::WriteDataPort()

gxsFTPClient::gxsFTPClient() - Default class constructor.

gxsFTPClient::~gxsFTPClient() -  Class destructor.

void gxsFTPClient::CloseDataPort() - Public member function used to close the FTP data port.

gxSocketError gxsFTPClient::ConnectClient(const char *host, int port = gxSOCKET_FTP_PORT) - Public member function used to connect a FTP client to a server. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPChDir(const char *dname) - Public member function used to change the current directory to the specified directory. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPDelete(const char *fname) - Public member function used to delete the specified file. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPGet(const char *fname, fstream &stream, unsigned &bytes) - Public member function used to download a file and write it to the specified file stream. Passes back the total number of bytes downloaded in the "bytes" variable. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPImageType(char type = 'I') - Public member function used to set the FTP image type to 'A' for ASCII transfers or 'I' for binary transfers. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPList(char *sbuf, unsigned bytes, int full = 1, const char *args = 0) - Public member function used to list the contents of the current working directory. The calling function must allocate a memory buffer for the directory listing and pass the buffer and buffer length to this function. If the directory listing exceeds the number of bytes allocated this function will return a buffer overflow. If the "full" variable is true this function will request a full directory listing. The "args" variable is used to add additional arguments to the list command sent to the FTP server. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPLogin(const char *username, const char *password) - Public member function used to logon to an FTP server. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPLogout() - Public member function used to logoff an FTP server. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPMkDir(const char *dname) - Public member function used to make the specified directory. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPMove(const char *from, const char *to) - Public member function used to rename an existing file. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPPWD() - Public member function used to get the present working directory. The results are stored in the "gxsFTPClient::reply_buf" string buffer. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPPut(const char *fname, fstream &stream, unsigned &bytes) - Public member function used to upload a file from the specified stream to the FTP server. Passes back the total number of bytes uploaded in the "bytes" variable. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPRmDir(const char *dname) - Public member function used to remove the specified directory. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPSize(const char *fname) - Public member function used to obtain the size of the specified file. The results are stored in the "gxsFTPClient::reply_buf" string buffer. Returns zero if no errors occur.

gxSocketError gxsFTPClient::FTPStat() - Public member function used to obtain the current FTP status. The results are stored in the "gxsFTPClient::reply_buf" string buffer. Returns zero if no errors occur.

gxSocketError gxsFTPClient::OpenDataPort() - Public member function used to open the client's FTP data port for file transfers. Returns zero if no errors occur.

int gxsFTPClient::ReadDataPort(void *buf, unsigned bytes) - Public member function used to read a specified number of bytes from the open data port using a non-blocking read. Returns the total number of bytes received or -1 if any errors occur.

int gxsFTPClient::RecvResponse(char *buf, int bytes, const char *response) - Public blocking receive function used to read a reply from an FTP server following a command. If the specified response is not received within the timeout period this function will return false to indicate an error. Returns true if successful.

int gxsFTPClient::RecvResponse(gxsSocket_t s, char *buf, int bytes, const char *response) - Public blocking receive function used to read a reply from an FTP server following a command. If the specified response is not received within the timeout period this function will return false to indicate an error. Returns true if successful.

gxSocketError gxsFTPClient::SendCommand(const char *command, const char *response, const char *args = 0) - Public member function used to send a command to an FTP server and read the server's response. Returns zero if no errors occur.

void gxsFTPClient::SetTimeOut(int seconds, int useconds) - Public member function used to set the FTP timeout values.

int gxsFTPClient::WaitForReply(gxsSocket_t s) - Public member function that returns false if a reply time is longer then the timeout values.

int gxsFTPClient::WriteDataPort(void *buf, unsigned bytes) - Public member function used to write a specified number of bytes to data port using a block write. Returns the total number of bytes transmitted or -1 if any errors occur.


End Of Document