From 772aae8b1dca9b14117aa3716286d763b6f3da88 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 7 Oct 2019 11:31:33 -0400 Subject: lib: Add getsockopt_so_recvbuf Add a new function getsockopt_so_recvbuf which tells you the operating systems receive buffer size. Signed-off-by: Donald Sharp --- lib/sockopt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/sockopt.c') diff --git a/lib/sockopt.c b/lib/sockopt.c index 8e38a2927..7726d74ff 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -72,6 +72,21 @@ int getsockopt_so_sendbuf(const int sock) return optval; } +int getsockopt_so_recvbuf(const int sock) +{ + uint32_t optval; + socklen_t optlen = sizeof(optval); + int ret = getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&optval, + &optlen); + if (ret < 0) { + flog_err_sys(EC_LIB_SYSTEM_CALL, + "fd %d: can't getsockopt SO_RCVBUF: %d (%s)", sock, + errno, safe_strerror(errno)); + return ret; + } + return optval; +} + static void *getsockopt_cmsg_data(struct msghdr *msgh, int level, int type) { struct cmsghdr *cmsg; -- cgit v1.2.3