Using Win32 functions in Visual FoxPro Image Gallery
Windows Sockets 2 (Winsock)
..msdn
accept
bind
closesocket
gethostbyaddr
gethostbyname
gethostname
getnameinfo
getprotobyname
getprotobynumber
getservbyname
getservbyport
getsockopt
htonl
htons
inet_addr
inet_ntoa
listen
ntohl
ntohs
recv
recvfrom
send
sendto
setsockopt
socket
WSACleanup
WSACloseEvent
WSAConnect
WSACreateEvent
WSAEnumProtocols
WSAEventSelect
WSAGetLastError
WSARecv
WSASend
WSAStartup
WSAWaitForMultipleEvents
ws_connect
ws_select
Code examples:
Winsock: connecting to a news server (NNTP, port 119)
Winsock: reading email messages (POP3, port 110)
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Winsock: sending email messages (SMTP, port 25)
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
This example shows how to connect to an FTP server using the anonymous access, and then establishing passive mode data connection to retrieve a directory listing.



Related exampleSee also:
  • Wininet: custom FTP class
  • Using FTPCommand

    Complete FTP solution:
    Download FTP Class Library
  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    7756 bytes  
    Created: 2003-02-16 19:17:30  
    Modified: 2010-01-02 14:40:52  
    Visits in 7 days: 73  
    Listed functions:
    closesocket
    gethostbyname
    htons
    inet_addr
    inet_ntoa
    recv
    send
    socket
    WSACleanup
    WSACloseEvent
    WSACreateEvent
    WSAEventSelect
    WSAGetLastError
    WSAStartup
    WSAWaitForMultipleEvents
    Printer friendly API declarations
    My comment:
    There is an article I would like to recommend -- Secrets of FTP -- on the VBIP site.

    It has been written for VB programmers learning how to use the Winsock control. Even if we are bound to Winsock API functions in Visual FoxPro, this article contains essential information for FTP programming with Winsock API.

    For downloading a file from the server change LIST to RETR command accompanied with a remote file name. The program code is very basic with a limited error checking, so may be start with downloading small files.

    FTP is an unusual service in that it utilizes two ports, a "data" port and a "command" port (also known as the control port). Another article I want to recommend is Active FTP vs. Passive FTP, a Definitive Explanation by Jay Ribak.

    * * *
    To create a passive data connection to an FTP server with WinINet, use INTERNET_FLAG_PASSIVE for dwFlags parameter in the InternetConnect call:

    #DEFINE INTERNET_INVALID_PORT_NUMBER 0
    #DEFINE INTERNET_SERVICE_FTP 1
    #DEFINE INTERNET_FLAG_PASSIVE 0x08000000

    nFlags = INTERNET_FLAG_PASSIVE
    && use 0 for the active mode

    hConnection = InternetConnect(m.hInternet, m.host,;
            INTERNET_INVALID_PORT_NUMBER,;
            m.usr, m.cPsw, INTERNET_SERVICE_FTP, m.nFlags, 0)


    #kwd: sln_ftp, sln_winsock
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.227.17.101)
    17 sec.Function: 'CeGetStoreInformation'
    Function group: 'Remote Application Programming (RAPI)'
    34 sec.
    Function group: 'System Shutdown'
    53 sec.
    Function group: 'Shell Lightweight Utility APIs -- Path Functions'
    1.18 min.Function: 'GetUserName'
    1.5 min.Example: 'Printing text with the Escape function'
    1.85 min.Function: 'CeRapiInitEx'
    Function group: 'Remote Application Programming (RAPI)'
    2.12 min.Function: 'SHCreateDirectory'
    Function group: 'Shell Functions'
    2.4 min.Function: 'GetMenuContextHelpId'
    Function group: 'Shell Functions'
    2.7 min.Function: 'SHQueryRecycleBin'
    Function group: 'Shell Functions'
    2.98 min.Function: 'LoadResource'
    Function group: 'Resource'
    Google
    Advertise here!