FTP_API int FtpDaemon ( FtpConfigData *pConfig )
pConfig | pointer to the config data for the server |
Returns 0 it daemon was started, or an error code greather zero:
FTP_ERR_NONE | 0 | no error |
FTP_ERR_SOCKET | 1 | socket error |
FTP_ERR_ISRUNNING | 2 | ftp server is allready running |
FTP_ERR_WRONGIP | 4 | the ip address is wrong |
FTP_ERR_INIT | 5 | initialization error |
FTP_ERR_WRONGPATH | 7 | a wrong path was defined |
FTP_ERR_NEED_LOGINCB | 10 | we need a login callback |
Description for FtpConfigData:
char cIpAddress[64] ip addres off the ftp-server.
use "0.0.0.0" for all addresses.
char cFilePath[256] is the base path for server files.
unsignedshort usTcpPort is the tcp port for the server.
usually this value is 21. (0=default)
unsigned uTimeout receive timeout in milliseconds.
int iMaxConnections maximum count of client connections.
int iPriority taks priority 0-256. (256=maximum)
int iReadOnly is the path read only.
int iNoAnonym don't allow an anonymous login.
FtpLoginCB pCbLogin callback for client connection
use NULL for no callback
is called if a a user logons on the
server.
Here you can use FtpInsertTreeEntry
to add shares to the currend session.
FtpConnectCB pCbConnect callback for client connection
use NULL for no callback
is called if a ftp client opens a
new connection to the server.
in this callback you can refuse
a connection from a specific target.
FtpDisconnectCB pCbDisconnect callback for client disconnection
use NULL for no callback
is called if a browser connection
is broken
FtpFileCheckerCB pCbChecker callback for single file access checking
use NULL for no callback
is called at every fille acces and
direcory enumeration
this member ist the callback for enties
which aren't createt with FtpInsertTreeEntry
void * pCbCheckerParam is the user parameter for the file
checking callback
See here for the depentencies of the callbacks.
i.e.:
... FtpConfigData sConfig; memset(&sConfig,0,sizeof(sConfig)); strcpy(sConfig.cIpAddress,"0.0.0.0" ); strcpy(sConfig.cFilePath ,"C:\\Temp"); sConfig.iMaxConnections = 4; sConfig.uTimeout = 1000*60*2; sConfig.pCbLogin = MyLoginCallback; sConfig.pCbConnect = MyConnectCallback; sConfig.pCbDisconnect = MyDisconnectCallback; if(FtpDaemon(&sConfig)) { // error switch(iRet) { case FTP_ERR_SOCKET: printf("socket error\n" ); break; case FTP_ERR_ISRUNNING: printf("ftp server is allready running\n"); break; case FTP_ERR_ISNOTRUNNING: printf("ftp server is not running\n" ); break; case FTP_ERR_WRONGIP: printf("the ip address is wrong\n" ); break; case FTP_ERR_INIT: printf("initialization error\n" ); break; case FTP_ERR_WRONGPATH: printf("wrong path name\n" ); break; case FTP_ERR_NEED_LOGINCB: printf("we need a login callback\n" ); break; default: printf("unknown erro %i\n",iRet ); break; } } else{ // wait until end // ... HttpStopDaemon(); }
see also:
AzFtp Overview |
FtpStopDaemon