Reputation: 357
I am hoping to create a small program to transfer data (strings, numeric data, documents, images and audio). I have read that UDP does not check if packets reach where their destination (thus it's easy to lose data) whereas TCP will re-send lost packets.
Will there be a big data-loss problem (using UDP) if I'm transfering data between 2 computers directly connected via crossover cabled etherent? I assumed there wouldn't be as the data is travelling only a few metres and is not going via any other hardware such as a router/server.
I have done very little network programming and so this is a short venture instead of using memory sticks/FTP/Filesharing etc to transfer the data.
Upvotes: 0
Views: 745
Reputation: 9569
Use TCP. It's deliberately designed to ensure complete and accurate data transfer in sequence. UDP is none of those. Packets can get dropped anywhere along the path, including inside the sending computer. Packets can get re-ordered for any reason - UDP doesn't care about order. What you probably can ignore is the possibility of data corruption - direct transfer like this won't have such issues.
But seriously, use TCP.
Upvotes: 1
Reputation: 1840
It doesn't sound like your data could handle any packets being lost, so unless you are going to be check-summing you data and verifying that everything made it across, use TCP.
If packets can be lost then you have to plan on them being lost or otherwise plan on your data being lost.
EDIT:
Distance will definitely impact the loss of packets, if the cable is long enough you will experience 100% loss. Now the question is, will you see a difference in loss with cables lengths that are within the spec of Ethernet. In theory if your cable is in spec then no you will not have lost packets, but this does not account for environmental issues. You could have a very short cable length that runs parallel to an AC power lines that has significant data corruption.
Either you can accept data loss or not. If not, then you should probably use TCP.
Upvotes: 1