summaryrefslogtreecommitdiff
path: root/src/libstddjb/socket_tryr.c
blob: 26c04b28840a8c11628939ec417cccea873198f6 (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)) return ;
    size -= (size >> 5) ;
  }
}