ftp LIST in C

From: zhisol (zhisol@o2.pl)
Date: 04/24/03


From: "zhisol" <zhisol@o2.pl>
Date: Thu, 24 Apr 2003 20:32:04 +0200

I've stated writing simple application for linux that list directory of
ftp server. I plan list subdirectories, too. But now, i have a PROBLEM.
I use sockets.

Connecting is simple, after assigni used only:
        sd=socket(...) //sd-socket descriptor
        connect(sd,...)
for USER, PASS, TYPE A, PASV, PWD i used:
        send(sd,"USER\r\n",...)
        recv(sd,...)
        [...]

and everything was OK, but with LIST... here i have BIG problem.
How can i receive data from ftp? Loop with recv() do nothing :(

I suppose that list return data and require new port open on client, but
i don't know how can i know which port number? For connection to ftp i
open port 21 and that's ok, but what know, I jammed :(.

Could You help me?

#cut of my code:
        [...]
        send(sd,"LIST\r\n", strlen("LIST") + 2, 0);
        n = recv (sd, buf, sizeof (buf), 0); //sd-socket descriptor
        while (n > 0)
        {
                buf[n] = '\0';
                printf ("%s", buf);
                n = recv (sd, buf, sizeof (buf), 0);
        }

PS:sorry for my english;)

-- 
pozdr.;)
zhisol


Relevant Pages

  • Re: 500 "LPRT 6,16,0,0,0,0...,34,113,2,7,184 New Information
    ... Try change it to port 21 and test again. ... if ftp is not bind to default port. ... >>Cleared up an issue with our firewall and now, ... >>connecting to 192.xxx.xxx.xxx:4774 ...
    (microsoft.public.inetserver.iis.ftp)
  • Re: Extremely abnormal behaviour: ftp client does show a file list in a folder occasionally
    ... from the first log u see the port range is within the range. ... IIS FTP to take effects. ... connecting to xxx.xxx.xx.xx:5013 ...
    (microsoft.public.inetserver.iis.ftp)
  • RE: Telnet/ftp problems SBS2000
    ... Please make sure your client computers are configured as both Firewall ... will find two options "Enable folder view for FTP sites" and "Use Passive ... that the control connection has been successfully established, ... (other than port 21) ...
    (microsoft.public.windows.server.sbs)
  • FTP transfer port
    ... FTP transfer port ... the FTP server "listens" for client connections on its port 21. ... it will establish a separate control connection and data connection with ...
    (bit.listserv.ibm-main)
  • Re: Hacked? External address knocks on internal private address...
    ... The important part of your message is that FTP is allowed out... ... You open a connection to an FTP Server and logon. ... When you ask the server for a file the server issues a "PORT" command ... so it can open a port on the firewall to allow the incoming Data ...
    (comp.security.firewalls)