Function Reference


_FTP_Connect

Connects to an FTP server

#include <FTPEx.au3>
_FTP_Connect ( $hInternetSession, $sServerName, $sUsername, $sPassword [, $iPassive = 0 [, $iServerPort = 0 [, $iService = $INTERNET_SERVICE_FTP [, $iFlags = $INTERNET_FLAG_DEFAULT [, $fuContext = 0]]]]] )

Parameters

$hInternetSession as returned by _FTP_Open()
$sServerName Server name/ip.
$sUsername Username.
$sPassword Password.
$iPassive [optional] Passive mode. Default is 0. See remarks.
$iServerPort [optional] Server port ( 0 is default (21) )
$iService [optional] This can be one of the following constant values:
    $INTERNET_SERVICE_FTP (1) - FTP service (default value)
    $INTERNET_SERVICE_GOPHER (2) - Gopher service. Available only on Windows XP, Windows Server 2003 R2 or earlier.
    $INTERNET_SERVICE_HTTP (3) - HTTP service.
$iFlags [optional] Special flags.
    $INTERNET_FLAG_DEFAULT (0)
    $INTERNET_FLAG_PASSIVE (0x08000000)
    $INTERNET_FLAG_TRANSFER_ASCII (1)
    $INTERNET_FLAG_TRANSFER_BINARY (2)
$fuContext [optional] A variable that contains the application-defined value that associates this search with any application data.
This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: an handle to connected session.
Failure: 0 and sets the @error flag to non-zero.

Remarks

The return handle must be closed with _FTP_Close().
If $iPassive is set to 1, then the special flag $INTERNET_FLAG_PASSIVE is automatically combined with the user's $iFlag parameter.

Related

_FTP_Close, _FTP_Command, _FTP_DirCreate, _FTP_DirDelete, _FTP_DirGetCurrent, _FTP_DirPutContents, _FTP_DirSetCurrent, _FTP_FileDelete, _FTP_FileGet, _FTP_FileGetSize, _FTP_FilePut, _FTP_FileRename, _FTP_ListToArray, _FTP_ListToArray2D, _FTP_ListToArrayEx, _FTP_Open, _FTP_SetStatusCallback

See Also

Search InternetConnect in MSDN Library.

Example

#include <FTPEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    Local $sServer = 'ftp.csx.cam.ac.uk' ; UNIVERSITY OF CAMBRIDGE ANONYMOUS FTP SERVER
    Local $sUsername = ''
    Local $sPass = ''
        Local $Err, $sFTP_Message

    Local $hOpen = _FTP_Open('MyFTP Control')
    Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error)
    Else
        _FTP_GetLastResponseInfo($Err, $sFTP_Message)
        ConsoleWrite('$Err=' & $Err & '   $sFTP_Message:' & @CRLF & $sFTP_Message & @CRLF)
        ; do something ...
    EndIf
    Local $iFtpc = _FTP_Close($hConn)
    Local $iFtpo = _FTP_Close($hOpen)
EndFunc   ;==>_Example