summaryrefslogtreecommitdiff
path: root/src/libstddjb/socket_tryr.c
blob: 6544c9d53d0169334f3ea3181c88844fb1d76c8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* ISC license. */

#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <skalibs/socket.h>

void socket_tryreservein (int s, unsigned int size)
{
  while (size >= 1024)
  {
    if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof size) == 0) return ;
    size -= (size >> 5) ;
  }
}