… | |
… | |
31 | # include <sys/socket.h> |
31 | # include <sys/socket.h> |
32 | # include <netinet/in.h> |
32 | # include <netinet/in.h> |
33 | # include <netinet/tcp.h> |
33 | # include <netinet/tcp.h> |
34 | #endif |
34 | #endif |
35 | |
35 | |
|
|
36 | #define HAVE_SIOCOUTQ 1 //TODO configure.ac support |
|
|
37 | #if HAVE_SIOCOUTQ |
|
|
38 | # include <linux/sockios.h> |
|
|
39 | #endif |
|
|
40 | |
36 | // disconnect a socket after this many seconds without an ack |
41 | // disconnect a socket after this many seconds without an ack |
37 | #define SOCKET_TIMEOUT 8. |
42 | #define SOCKET_TIMEOUT 8. |
38 | |
43 | |
39 | // force a packet when idle for more than this many seconds, |
44 | // force a packet when idle for more than this many seconds, |
40 | // forcing an ack regularly. |
45 | // forcing an ack regularly. |
… | |
… | |
43 | void |
48 | void |
44 | client::flush () |
49 | client::flush () |
45 | { |
50 | { |
46 | if (destroyed ()) |
51 | if (destroyed ()) |
47 | return; |
52 | return; |
|
|
53 | |
|
|
54 | # if HAVE_SIOCOUTQ |
|
|
55 | { |
|
|
56 | int value; |
|
|
57 | |
|
|
58 | if (!ioctl (fd, SIOCOUTQ, &value)) |
|
|
59 | outq = value; |
|
|
60 | } |
|
|
61 | # endif |
48 | |
62 | |
49 | #if HAVE_TCP_INFO |
63 | #if HAVE_TCP_INFO |
50 | // check about once per second, spread evenly over all clients |
64 | // check about once per second, spread evenly over all clients |
51 | // do this only when player is active |
65 | // do this only when player is active |
52 | if (!((pticks + fd) & 7) && pl && pl->active) |
66 | if (!((pticks + fd) & 7) && pl && pl->active) |