Dave's Brain

Browse - Programming Tips - Ftp opens another socket every time it lists a directory's contents.

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.  They 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-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.