How to check the capacity of a TCP send buffer to ensure data delivery

前端 未结 2 775
耶瑟儿~
耶瑟儿~ 2021-01-07 14:48

I would like to add delivery confirmation to my TCP interface. A non-blocking write could populate the send buffer, but the data might never arrive if the connection fails

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-07 15:47

    TCP ensures only OS-level delivery. It means, for example, that if your receiver application crashes unexpectedly in the middle of transmission, your sender can't be sure that all data is received -- consider when remote TCP stack sends ack about data received, but your application don't get a chance to process this data.

    That's why you may need application-level acknowledgement scheme. For example, you may employ the same technique as TCP stack does -- use ack numbers, only this time on application level. If your remote app sends you ack number X, you may be sure that X data items are indeed received and processed by app, not by OS TCP stack.

提交回复
热议问题