Search /
Docfinder:
Advanced search  |  Help  |  Site map
RESEARCH CENTERS
SITE RESOURCES
Click for Layer 8! No, really, click NOW!
Networking for Small Business
TODAY'S NEWS
The botnet world is booming
What’s driving this university to IPv6? Going green
How ending exclusivity agreements would change the telecom industry
How to use electrical outlets and cheap lasers to steal data
EMC distances rival NetApp
Crime lab saves energy costs by turning up heat in the data center
IBM security software masks confidential info
Google Native Client provides hints on Chrome OS gambit
Ericsson signs deal to run Sprint wireless, wireline networks
Verizon helping companies assess application vulnerabilities
Internet's biggest issue? IPv6 transition, new ARIN CEO says
Gmail, other Google apps, out of beta
Microsoft may have known about critical IE bug for months
Symantec de-duplication strategy targets data growth, virtual machines
Windows 7 ramp-up will be sharp
Applications /

More FTPing

Gearhead archive

In our exploration of how FTP works that we began last week, we got a connection to an FTP server, authenticated ourselves, selected the data transfer type and found out what the default directory was. Now we need to find out what is in the directory, and here's where things get interesting. The server doesn't send data on the same connection that the client uses for commands - a separate port is used, and the client has two ways to handle the connection.

The passive mode (the command is "pasv") tells the server that the client will initiate the data transfer. In response, the server tells the client which port will be used (the first line is the client command and the next is the server's response prefaced with the operation's status code).

PASV
227 Entering Passive Mode
(199,201,128,19,42,204)

The client then creates a TCP connection to the given port and reads the data.

Advertisement:

Note that the reply codes that start each response line are grouped thusly: 1yz for Positive Preliminary replies, 2yz for Positive Completion replies, 3yz for Positive Intermediate replies, 4yz for Transient Negative Completion replies, and 5yz for Permanent Negative Completion replies. The "y" part gives a finer resolution of the status: 0 refers to syntax errors, 1 is for information, 2 for connections, 3 for authentication and accounting, 4 is unspecified, and 5 concerns file system status.

In the example above, the first 2 means we have completed the command and the second 2 means it involved a connection. The final digit (z) is very specific, and you should refer to RFC 959 for the details.

The alternative to passive mode is that the server is told, using the "port" command, to connect to a specific port on a specific IP address and then start to transfer the data. So:

PORT 10,0,0,102,14,159
200 PORT command successful.

Now we need to get the directory listing. The command "list" will return the contents of the current working directory or, if a path is given, a specified directory. The tricky part here is for the client to determine what the listing means because the server's reply will depend on whatever listing format the server's operating system supplies.

Many FTP clients understand the format returned by specific vendors and versions of an FTP server. The server type can be determined by the system command ("syst"), and the result will be a string as specified in RFC 1700 (see RFC 1700- it's a huge RFC and you'll need to search for "OPERATING SYSTEM NAMES"). To really get it right, FTP client developers have to look for more clues to determine not only the operating system but also the FTP server implementation to which they are talking.

The command "nlst" will return just the file names (that is, without other directory data), and the "cwd" command lets you change the default directory. You can also go back up the directory tree with the change directory up command ("cdup"). Other directory operations include remove directory ("RMD ") and make directory ("MKD "), but note all directory and file operations are limited to privileges you have through your logon account.

Next week, we get and put files. Comments to gearhead@gibbs.com.

RELATED LINKS

Comments and suggestions to gh@gibbs.com.

Gibbs Forum
The place to discuss Gibbs's columns.

Check out this week's edition of

Backspin for more musings from Gibbs.

Part 1: Intro to FTP
Network World, 7/23/01.

Part 3: Connection modes
Network World, 8/6/01.

Part 4: Let the transfers begin
Network World, 8/13/01.

Part 5: FTP server security
Network World, 8/20/01.

Part 6: SITE and SYST
Network World, 8/27/01.


NWFusion offers more than 40 FREE technology-specific email newsletters in key network technology areas such as NSM, VPNs, Convergence, Security and more.
Click here to sign up!
New Event - WANs: Optimizing Your Network Now.
Hear from the experts about the innovations that are already starting to shake up the WAN world. Free Network World Technology Tour and Expo in Dallas, San Francisco, Washington DC, and New York.
Attend FREE
Your FREE Network World subscription will also include breaking news and information on wireless, storage, infrastructure, carriers and SPs, enterprise applications, videoconferencing, plus product reviews, technology insiders, management surveys and technology updates - GET IT NOW.
* HOME    * RESEARCH CENTERS     * NEWS     * EVENTS

Contact us | Terms of Service/Privacy | How to Advertise
Reprints and links | Partnerships | Subscribe to NW
About Network World, Inc.

Copyright, 1994-2006 Network World, Inc. All rights reserved.