LInetFtp::Connect

#include "ltwrappr.h"

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

L_

L_TCHAR L_FAR *pszServer;

/* name of server to connect to */

L_TCHAR L_FAR *pszUserName;

/* username for authentication */

L_TCHAR L_FAR *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::DeleteFile, 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_VOID TestConnect(HWND hWndParent)
{
   LInetFtp InetFtp(TEXT("www.leadtools.com"));

   // Checking if the connection failed
   if(InetFtp.GetErrorFromList () != SUCCESS)
   {
      InetFtp.DisplayError (hWndParent, TEXT("Can't connect to the FTP server"));
      return;
   }

   // Another code

   InetFtp.Disconnect ();

   if(InetFtp.Connect(TEXT("www.leadtools.com"), TEXT("ABC"), TEXT("XYZ")) != SUCCESS)
   {
      InetFtp.DisplayError(hWndParent, TEXT("Can't connect to the FTP server, user-name or password may invalid!!"));
      return;
   }
}