Re: ftp LIST in C
From: Dragan Cvetkovic (d1r2a3g4a5n.NOSPAM@SPAM.t6h7t.net)
Date: 04/24/03
- Next message: scriptOmatic: "Re: ftp LIST in C"
- Previous message: zhisol: "ftp LIST in C"
- In reply to: zhisol: "ftp LIST in C"
- Next in thread: scriptOmatic: "Re: ftp LIST in C"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: Dragan Cvetkovic <d1r2a3g4a5n.NOSPAM@SPAM.t6h7t.net> Date: 24 Apr 2003 14:40:28 -0400
"zhisol" <zhisol@o2.pl> writes:
> 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 :(.
You need to read RFC 959 (ftp://ftp.rfc-editor.org/in-notes/rfc959.txt):
control connection
The communication path between the USER-PI and SERVER-PI for
the exchange of commands and replies. This connection follows
the Telnet Protocol.
data connection
A full duplex connection over which data is transferred, in a
specified mode and type. The data transferred may be a part of
a file, an entire file or a number of files. The path may be
between a server-DTP and a user-DTP, or between two
server-DTPs.
On most UNIX systems control connection uses port 21 (ftp) and data uses
port 20 (ftp-data).
HTH, Dragan
-- Dragan Cvetkovic, To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer
- Next message: scriptOmatic: "Re: ftp LIST in C"
- Previous message: zhisol: "ftp LIST in C"
- In reply to: zhisol: "ftp LIST in C"
- Next in thread: scriptOmatic: "Re: ftp LIST in C"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|