From af789073a702e73b1e0b27995068a8770b8a5ce7 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 12 Feb 2025 14:34:23 -0400 Subject: [PATCH] MT#61625 add socket_rcvtimeout helper Change-Id: I17de1f5948e64712fb60bd96708c07ea87cfe010 --- lib/socket.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/socket.h b/lib/socket.h index a5830f962..e252ba194 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -251,6 +251,11 @@ INLINE void nonblock(int fd) { // coverity[check_return : FALSE] fcntl(fd, F_SETFL, O_NONBLOCK); } +INLINE void socket_rcvtimeout(socket_t *s, unsigned int us) { + struct timeval tv = timeval_from_us(us); + // coverity[check_return : FALSE] + setsockopt(s->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); +} INLINE int socket_cpu_affinity(socket_t *s, int cpu) { #ifndef SO_INCOMING_CPU errno = ENOTSUP;