Finding out if a message over tcp was delivered

后端 未结 6 1599
情深已故
情深已故 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:09

    Application layer has no control over the notifications at lower layers (such as the Transport layer) unless they are specifically provided - this is by design. If you want to know what TCP is doing on a per packet level you need to find out at the layer that TCP operates at; this means handling TCP headers and ACK data.

    Any protocol you end up using to carry your payload can be used to pass messages back and forth by way of that payload, however. So if you feel awkward using the bits of a TCP header to do this, simply set it up in your application. For instance:

    A: Send 450 Bytes
    B: Recv 450 Bytes
    B: Send 'B received 450 Bytes'
    A: Recv 'B received 450 Bytes'
    A: Continue
    

提交回复
热议问题