Finding out if a message over tcp was delivered

后端 未结 6 1596
情深已故
情深已故 2020-11-29 08:29

When i send()/write() a message over a tcp stream, how can i find out if those bytes were successfully delivered?

The receiver acknowledges receiving the bytes via t

6条回答
  •  庸人自扰
    2020-11-29 09:21

    The TCP protocol tries very hard to make sure your data arrives. If there is a network problem, it will retransmit the data a few times. That means anything you send is buffered and there is no timely way to make sure it has arrived (there will be a timeout 2 minutes later if the network is down).

    If you need a fast feedback, use the UDP protocol. It doesn't use any of the TCP overhead but you must handle all problems yourself.

提交回复
热议问题