This source file includes following definitions.
- rpl_setsockopt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <config.h>
21
22 #define WIN32_LEAN_AND_MEAN
23
24 #include <sys/socket.h>
25
26
27 #include <sys/time.h>
28
29
30 #include "w32sock.h"
31
32 #undef setsockopt
33
34 int
35 rpl_setsockopt (int fd, int level, int optname, const void *optval, socklen_t optlen)
36 {
37 SOCKET sock = FD_TO_SOCKET (fd);
38 int r;
39
40 if (sock == INVALID_SOCKET)
41 {
42 errno = EBADF;
43 return -1;
44 }
45 else
46 {
47 if (level == SOL_SOCKET
48 && (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO))
49 {
50 const struct timeval *tv = optval;
51 int milliseconds = tv->tv_sec * 1000 + tv->tv_usec / 1000;
52 optval = &milliseconds;
53 r = setsockopt (sock, level, optname, optval, sizeof (int));
54 }
55 else
56 {
57 r = setsockopt (sock, level, optname, optval, optlen);
58 }
59
60 if (r < 0)
61 set_winsock_errno ();
62
63 return r;
64 }
65 }