Re: ftp LIST in C
From: Adie (a_usenetizen@hotmail.com)
Date: 04/25/03
- Next message: Andrew Gierth: "Re: blocking signals in signal handler -- True or False quiz"
- Previous message: Måns Rullgård: "Re: conf files."
- In reply to: zhisol: "ftp LIST in C"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: Adie <a_usenetizen@hotmail.com> Date: Fri, 25 Apr 2003 00:49:26 +0100
"zhisol" <zhisol@o2.pl> wrote:
>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;)
There are two connections needed, port 21 for commands, port 20 for
data. Youre asking for data, "LIST" on port 21 returns *data* and
hence is sent to port 20.
- Next message: Andrew Gierth: "Re: blocking signals in signal handler -- True or False quiz"
- Previous message: Måns Rullgård: "Re: conf files."
- In reply to: zhisol: "ftp LIST in C"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|