… | |
… | |
46 | #include <unistd.h> |
46 | #include <unistd.h> |
47 | #include <arpa/inet.h> |
47 | #include <arpa/inet.h> |
48 | |
48 | |
49 | #include <algorithm> |
49 | #include <algorithm> |
50 | |
50 | |
|
|
51 | // use relatively small values, as we do not expect to receive much, |
|
|
52 | // and we do userspace write buffering |
|
|
53 | // 8kb limits throughput to roughly 66kb/s |
|
|
54 | #define SOCKET_RCVBUF 8192 |
|
|
55 | #define SOCKET_SNDBUF 16384 |
|
|
56 | |
51 | sockvec clients; |
57 | sockvec clients; |
52 | |
58 | |
53 | /** |
59 | /** |
54 | * Initializes a connection. Really, it just sets up the data structure, |
60 | * Initializes a connection. Really, it just sets up the data structure, |
55 | * socket setup is handled elsewhere. We do send a version to the |
61 | * socket setup is handled elsewhere. We do send a version to the |
… | |
… | |
74 | LOG (llevError, "SO_LINGER: %s\n", strerror (errno)); |
80 | LOG (llevError, "SO_LINGER: %s\n", strerror (errno)); |
75 | } |
81 | } |
76 | |
82 | |
77 | { |
83 | { |
78 | int val; |
84 | int val; |
|
|
85 | |
|
|
86 | #ifdef SO_RCVBUF |
|
|
87 | val = SOCKET_RCVBUF; |
|
|
88 | if (setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &val, sizeof (val))) |
|
|
89 | LOG (llevError, "SO_RCVBUF: %s\n", strerror (errno)); |
|
|
90 | #endif |
|
|
91 | |
|
|
92 | #ifdef SO_SNDBUF |
|
|
93 | val = SOCKET_SNDBUF; |
|
|
94 | if (setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &val, sizeof (val))) |
|
|
95 | LOG (llevError, "SO_SNDBUF: %s\n", strerror (errno)); |
|
|
96 | #endif |
79 | |
97 | |
80 | #ifdef IP_TOS |
98 | #ifdef IP_TOS |
81 | val = IPTOS_LOWDELAY; |
99 | val = IPTOS_LOWDELAY; |
82 | if (setsockopt (fd, IPPROTO_IP, IP_TOS, &val, sizeof (val))) |
100 | if (setsockopt (fd, IPPROTO_IP, IP_TOS, &val, sizeof (val))) |
83 | LOG (llevError, "IP_TOS: %s\n", strerror (errno)); |
101 | LOG (llevError, "IP_TOS: %s\n", strerror (errno)); |