Davut Özcan
Davut Özcan

Reputation: 109

How reliable is a TCP connection?

I have been writen server-client application.Server is coded in c# and the client code writen using java.The communication protocol is TCP.

While transfering a file using tcp is it possible to send missing data. In other words does tcp guarantee that data arrives correctly.(Should I send header information for this file in order to check errors , like file size , hash etc.)

Upvotes: 2

Views: 1149

Answers (2)

Roland Bär
Roland Bär

Reputation: 1730

The ordering of the packages of a tcp transmission os reliable.

For example your tcp message is split in three packages A, B and C.

Your client receives A, package B gets lost and then the client receives C. In the stream you will get only package A, package C is stored and as soon package B is retransmitted and received by your client, in the stream you will get package B and then C.

The same is done if package B is routed throug another way and is therefor received after package C.

The field 'Sequence Number' in the tcp header is needed for this mechanism.

Upvotes: 3

Zhongzhi
Zhongzhi

Reputation: 436

TCP provides a 16-bit checksum in protocol. It can detect most of the errors. Mistakes are more likely made at upper levels rather than tcp/ip. If you need high reliability in your software, an end-to-end strategy could be considered.

There is a classic article which talks about this: "end to end arguments in system design".

Upvotes: 3

Related Questions