views:

177

answers:

3

Among FTP, HTTP, SSH, etc. and given a consistent, broadband internet connection what is the fastest way to transfer files over a network?

A: 

Do you have control over both endpoints and any intervening firewalls? FTP is less firewall-friendly than the other options. SSH-based tools (sftp, scp) are pretty good, but some ISPs have been known to throttle or otherwise interfere with encrypted traffic (Comcast, I'm lookin' at you!) Have you considered rsync? At my work, that's what we use for transferring huge datasets over long-haul internet connections.

Jim Lewis
+1  A: 

Among these 3, its HTTP. The effective act of "transfering the file" has the same speed, but:

FTP requires too much "conversation" to stabilize a session, and creates parallel connections to transfer data, all this "talking" takes a little more time to begin transfering files. For this same reason you may have trouble with firewalls and routers because of FTP opening random ports, specialy if the FTP client doesn't support "passive mode".

HTTP is more objective, you connect, tell what you want, and get it as answer. No blah blah blah.

SSH is not a transfer protocol. SSH stands for "Secure Shell". If you mean SSL, it is also not a transfer protocol, its a security layer, commonly used encapsulating HTTP sessions.

But maybe its not a matter of which one is faster, the real question is: what do you want to do? Depending on your problem, none of those may be an option.

Havenard
+1  A: 

Use Socket.SendFile() if you can. This is the easiest way to get a file from point A to point B. Without knowing the specifics of what you're trying to accomplish, it's really hard to give a better recommendation. FTP is probably what I would use otherwise and System.Net has a fairly decent FtpClient object that you can use and the samples document it fairly well. HTTP and FTP both use TCP so you're probably not going to see a significant speed difference between them and HTTP usually will have headers with other potential behavior (try uploading a file with Expect-100 Continue and no credentials to a server that requires AUTH and see what happens to your connections). With Socket.SendFile() since sockets are by definition protocol-agnostic, you could potentially send the file via UDP or TCP with the same code, but I would only recommend that if you're sending via a LAN where packet loss is virtually 0. UDP over the internet is not a good idea.

Jeff Tucker