socket_tryreservein.c (292B)
1 /* ISC license. */ 2 3 #include <skalibs/nonposix.h> 4 #include <sys/socket.h> 5 #include <skalibs/socket.h> 6 7 void socket_tryreservein (int s, unsigned int size) 8 { 9 while (size >= 1024) 10 { 11 if (!setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof size)) return ; 12 size -= (size >> 5) ; 13 } 14 }