Re: file transfer protocol (not FTP) examples
Re: file transfer protocol (not FTP) examples
- Subject: Re: file transfer protocol (not FTP) examples
- From: Joshua Graessley <email@hidden>
- Date: Wed, 9 Jul 2003 09:02:17 -0700
On Wednesday, July 9, 2003, at 0:34, Quinn wrote:
At 18:33 -0400 26/6/03, Philip D. Wasson wrote:
Is it really safe to essentially tell the receiver "OK, the file is
this many bytes long, sending now." and then just dump the file into
the socket (in reasonably-sized buffer-loads, of course).
Yes. TCP guarantees that either all of the data will arrive intact
and in order, or the connection will tear.
Sending a count before sending the data is generally a good idea. That
way the receiver can easily distinguish between the end of the data
and a torn connection. [A receiver that uses the APIs properly can do
this regardless, but having a length makes it more obvious.]
I would add to this that it is also a good idea to send a checksum of
the file, if it isn't too much trouble to calculate. With the increase
in usage of hardware checksums and various entities that rewrite/modify
checksums, like NATs, a small bug can lead to corruption that can not
be detected by TCP. For example, if a bug in an ethernet driver caused
it to smash a few bytes before handing the data off to the card where
the TCP checksum was calculated, TCP would be unable to detect this
error. Retrospect does a great job of verifying data sent across TCP.
As backup software, it doesn't trust anything, not even TCP. This makes
Retrospect a great tool for verifying that everything is working
correctly. scp will also checksum the data it copies.
Corruption in a TCP stream certainly isn't very common, but if your
software is sending important data (backups), it's worth it to do that
extra little sanity check to catch that one in a billion case where
something goes wrong.
-josh
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.