TFtpServer

Source: source/classes/tftpserv.prg

Standalone class

TFtpServer implements a basic FTP server using TSocket. It listens on port 21 and handles standard FTP commands (USER, PASS, STOR, RETR, LIST, CWD, PWD, QUIT). Supports anonymous access and serves files from a configurable root directory.

Key DATA Members

DATATypeDescription
oSocketObjectMain listening TSocket
cRootDirCharacterDefault FTP directory (default "ftp")
nPortNumericListening port (default 21)
lDebugLogicalEnable debug logging to cLogFile

Methods

MethodDescription
New( nPort )Create server; creates root dir if missing
Activate()Start listening for clients
End()Stop the server
OnAccept()Handle new client connections
OnRead( oSocket )Process FTP commands from a client

TFTP

Source: source/classes/tftp.prg

FTP client via WinINet. Supports directory listing, file deletion, rename, and directory management.

MethodDescription
New( cFTPSite, oInternet, cUser, cPass )Connect to an FTP site
Directory( cMask )Return array of remote file records
DeleteFile( cFile )Delete a remote file
RenameFile( cOld, cNew )Rename a remote file

TFTPFile

Source: source/classes/tftpfile.prg

Manages individual remote file transfers. Supports ASCII and binary modes.

MethodDescription
New( cFileName, oFTP )Create a file object
OpenRead() / OpenWrite()Open for reading or writing
Read( nBytes ) / Write( cData )Read or write data
Seek( nBytes, nFrom )Seek to a position
End()Close the file handle

Example: Start FTP Server

#include "FiveWin.ch"
function Main()
   local oServer
   oServer := TFtpServer():New( 21 )
   oServer:cRootDir = "c:\ftproot"
   oServer:lDebug   = .T.
   oServer:Activate()
return nil

Notes

See Also