Is Linux Socket send timeout means peer did not recv one byte data or did not finish recv all data in timeout duration?

64 Views Asked by At

If I set send timeout for a socket is 10ms, when timeout is happen, I don`t know the reason is peer did not recv at least one byte data or peer did not finish receive all of the data

1

There are 1 best solutions below

0
Remy Lebeau On

In TCP, send() times out when the outbound buffer of the sending socket fills up and can't accept more bytes within the timeout period.

This typically happens when the inbound buffer of the receiving socket does not have space to receive more bytes, so the sending socket caches outbound bytes waiting for the receiver to signal that it can accept bytes.

Since TCP is a stream, that can be as little as 1 byte. TCP has no concept of messages, so you have to pay attention to send()'s return value to know how many bytes it actually accepted.