From: Guus Sliepen Date: Sun, 17 Mar 2019 19:54:19 +0000 (+0100) Subject: Add functions to get the amount of bytes in the send and receive buffers. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=113cc69639c8148cb4ffb488065db41c09a861b3;p=utcp Add functions to get the amount of bytes in the send and receive buffers. utcp_get_sendq() returns the amount of bytes in the send buffer, which corresponds to the amount of bytes not yet ACKed by the peer. utcp_get_recvq() returns the amount of bytes in the receive buffer, which may or may not have been acked already, but have not been read by the application. --- diff --git a/utcp.c b/utcp.c index 9fb68ae..4875f84 100644 --- a/utcp.c +++ b/utcp.c @@ -1930,6 +1930,14 @@ void utcp_set_rcvbuf(struct utcp_connection *c, size_t size) { } } +size_t utcp_get_sendq(struct utcp_connection *c) { + return c->sndbuf.used; +} + +size_t utcp_get_recvq(struct utcp_connection *c) { + return c->rcvbuf.used; +} + bool utcp_get_nodelay(struct utcp_connection *c) { return c ? c->nodelay : false; } diff --git a/utcp.h b/utcp.h index fe4c720..5d64676 100644 --- a/utcp.h +++ b/utcp.h @@ -99,6 +99,9 @@ extern size_t utcp_get_rcvbuf(struct utcp_connection *connection); extern void utcp_set_rcvbuf(struct utcp_connection *connection, size_t size); extern size_t utcp_get_rcvbuf_free(struct utcp_connection *connection); +extern size_t utcp_get_sendq(struct utcp_connection *connection); +extern size_t utcp_get_recvq(struct utcp_connection *connection); + extern bool utcp_get_nodelay(struct utcp_connection *connection); extern void utcp_set_nodelay(struct utcp_connection *connection, bool nodelay);