TCP连接的可靠性如何? [英] How reliable is a TCP connection?
问题描述
我一直在写服务器客户端application.Server用c#编写,客户端代码用java编写。通信协议是TCP。
I have been writen server-client application.Server is coded in c# and the client code writen using java.The communication protocol is TCP.
传输文件时使用tcp可以发送丢失的数据。换句话说,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.)
推荐答案
tcp传输的软件包的顺序可靠。
The ordering of the packages of a tcp transmission os reliable.
例如,你的tcp消息分为三个包A,B和C。
For example your tcp message is split in three packages A, B and C.
您的客户端收到A,包B丢失,然后客户端收到C.在流中,您将只获得包A,包C被存储并且很快包B由您的客户重新发送和接收,在流中您将获得包B,然后是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.
如果包B通过另一种方式路由,则完成相同的操作因此在包C之后收到。
The same is done if package B is routed throug another way and is therefor received after package C.
此机制需要tcp头中的序列号字段。
The field 'Sequence Number' in the tcp header is needed for this mechanism.
这篇关于TCP连接的可靠性如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!