Skip to main content
GameDev.net gamedev.net
🔒 Locked

FTP communication

Started by MatsVed Nov 22, 2010 at 11:09 AM 2 replies 1.8k views
Original Post
MatsVed
MatsVed
When a Patch Server is trying to communicate with a browser using FTP, should the server turn off TCP_NODELAY?
Also, when wanting to communicate asynchronously, would it be considered good etiquette to send '220 Features: p.' ?
Oh and what encoding is the most common? ASCII or Unicode?
hplus0603
hplus0603
All of those questions have "it depends" answers.

My suggestion: NODELAY not needed, because FTP is a bulk protocol. However, if you aggregate your writes into a single send() in the implementation, turning it on will probably help a tiny bit.

Features line: Read the spec, and make up your own mind.

Encoding: For the text bits, you absolutely want ASCII, and extend to UTF-8 where needed. Turns out, that's pretty much automatic, as long as you don't do anything special when the high bit is set in a text string (like a filename).
Proper "Unicode" (as in ucs-16 or ucs-32) is terrible and I know of no servers that use that.
enum Bool { True, False, FileNotFound };
MatsVed
MatsVed
Thanks for your answers!

Now I've gotten to the point where the client wants my server to go into passive mode. So... does that mean I can direct the client to a port that I've already opened, or should I open a new port for each dataconnection?
The latter alternative strikes me as a bit... die-hard? Isn't there a limit on how many ports you can have open at the same time?
And if you simply receive all data-traffic on the same socket (same port), how do you distinguish data that belongs to one client from data that belongs to another client?
hplus0603
hplus0603
With active mode, you must use a new port for each connection to the same destination from the same source, because a TCP connection is defined by the tuple (source ip address, source tcp port, destination ip address, destination tcp port).

When using passive mode, my understanding is that the data flows on the same connection, so as to work through NAT firewalls that don't allow back connections. FTP is a terribly insecure and cumbersome protocol for file transfer, in general, although it's the only protocol I know of short of high-level remove shells that allows you to set up a transfer from machine A to machine B from machine C, without the data going through machine C.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.