Dave's Brain

Browse - programming tips - ftp get directory list without opening another connection

Date: 2007nov15

Q.  Ftp opens another socket every time it lists a directory's contents.
    Is there a way my program can avoid this overhead?

A.  The LIST and NLST server commands are usually done
    when a client program does ls or dir.  The open a new
socket and require either the POST or PASV commands before hand.

But the STAT command sends the same info and does not open
a new socket and associated complications.

To list the current directory do:

	STAT .

To list another directory do:

	STAT <dir>

You can also use:

	MDTM <file>
	SIZE <file>

To get a file's modify date/time and size via the same connection.

Add a comment

Sign in to add a comment
Copyright © 2008, dave - Code on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License.