There are (at least) two different pieces of information that you may need: the amount of data that has not yet been sent, and the amount of data that has been sent but not ACK-ed.
Linux: SIOCOUTQ , , ( + , ACK-ed). A ( 2016) tcpi_notsent_bytes TCP_INFO.
macOS iOS: getsockopt(fd, SOL_SOCKET, SO_NWRITE, ...) , SIOCOUTQ: , , ( + , ACK-ed). , .
Windows: GetPerTcpConnectionEStats TcpConnectionEstatsSendBuff , , ACK-ed .
, .