In most cases, the lpszLocalHost parameter should be omitted
or a NULL
pointer. On a multihomed system, this will enable
the server to accept connections on any appropriately configured
network adapter. Specifying a hostname or IP address will limit client
connections to that particular address. Note that the hostname or
address must be one that is assigned to the local system, otherwise an
error will occur.
If an IPv6 address is specified as the local address, the system
must have an IPv6 stack installed and configured, otherwise the
method will fail.
To listen for connections on any suitable IPv4 interface, specify
the special dotted-quad address "0.0.0.0". You can accept connections
from clients using either IPv4 or IPv6 on the same socket by
specifying the special IPv6 address "::0", however this is only
supported on Windows 7 and Windows Server 2008 R2 or later platforms. If
no local address is specified, then the server will only listen for
connections from clients using IPv4. This behavior is by design for
backwards compatibility with systems that do not have an IPv6 TCP/IP
stack installed.
The handle returned by this method references the
listening socket that was created when the server was started. The
service is managed in another thread, and all interaction with the
server and active client connections are performed inside the event
handlers. To disconnect all active connections, close the listening
socket and terminate the server thread, call the Stop
method.
The host UUID that is defined as part of the server configuration should
be generated using the uuidgen utility that is included with the
Windows SDK. You should not use the UUID that is provided in the
example code, it is for demonstration purposes only. If no host UUID
is specified in the server configuration, an ephemeral UUID will be
generated automatically when the server is started.
CFtpServer *pFtpServer = new CFtpServer();
// Initialize the server configuration
pFtpServer->SetName(_T("server.company.com"));
pFtpServer->SetUuid(_T("10000000-1000-1000-1000-100000000000"));
pFtpServer->SetDirectory(_T("%ProgramData%\\MyProgram\\Server"));
pFtpServer->SetLogFile(FTP_LOGFILE_EXTENDED, 5, _T("%ProgramData%\\MyProgram\\Server.log"));
pFtpServer->SetOptions(FTP_SERVER_LOCALUSER | FTP_SERVER_UNIXMODE);
// Start the server
pFtpServer->Start(FTP_PORT_DEFAULT);