LInetFtp::Connect

#include "ltwrappr.h"

L_INT LInetFtp::Connect(pszServer, pszUserName = NULL, pszPassword = NULL, nPort = 21)

L_TCHAR *pszServer;

/* name of server to connect to */

L_TCHAR *pszUserName;

/* username for authentication */

L_TCHAR *pszPassword;

/* password for authentication */

L_INT nPort;

/* port on the server to connect to */

Connects to the specified FTP server.

Parameter

Description

pszServer

Character string that contains the host name of an FTP server. This can be a URL, like ftp.leadtools.com, or it can contain the IP number of the site, in ASCII dotted-decimal format (for example, 208.35.195.11). This is a NULL-terminated string.

pszUserName

Character string that contains the name of the user logging on. Default value is NULL. This is a NULL-terminated string.

pszPassword

Character string that contains the password to use when logging on. If both pszPassword and pszUsername are NULL, the connection is made anonymously.

nPort

Number of the TCP/IP port on the server to connect to. These flags set only the port that will be used. Use the default port for FTP servers: INTERNET_DEFAULT_FTP_PORT (port 21).

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

A connection to an FTP server must be established before using any other FTP functions. If a connection is disconnected, via either LInetFtp::Disconnect or LInetFtp::~LInetFtp, then a connection must be re-established before any other FTP functions are called. LInetFtp::Connect and LInetFtp::LInetFtp can be used to establish a connection with an FTP server.

Required DLLs and Libraries

LTFIL
LTWEB

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

LInetFtp::LInetFtp, LInetFtp::Disconnect, LInetFtp::SendFile, LInetFtp::GetFile, LInetFtp::RenameFile, LInetFtp::RemoveFile, LInetFtp::CreateDir, LInetFtp::DeleteDir, LInetFtp::GetCurrentDir, LInetFtp::BrowseDir, LInetFtp::ChangeDir, LInetFtp::SendBitmap, Class Members

Topics:

FTP Functions: Connect / Disconnect Operations

 

How to Program with the LInetFtp Class

Example

L_INT LInetFtp_ConnectExample(HWND hWndParent) 
{
   L_INT nRet;
   LInetFtp InetFtp(TEXT("www.leadtools.com"));
   // Checking if the connection failed
   nRet = InetFtp.GetErrorFromList ();
   if(nRet != SUCCESS)
   {
      InetFtp.DisplayError (hWndParent, TEXT("Can't connect to the FTP server"));
      return nRet;
   }
   // Another code
   InetFtp.Disconnect ();
   nRet = InetFtp.Connect(TEXT("www.leadtools.com"), TEXT("ABC"), TEXT("XYZ"));
   if(nRet != SUCCESS)
   {
      InetFtp.DisplayError(hWndParent, TEXT("Can't connect to the FTP server, user-name or password may invalid!!")); 
      return nRet; 
   }
   return SUCCESS;
}