ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/lowlevel.C
(Generate patch)

Comparing deliantra/server/socket/lowlevel.C (file contents):
Revision 1.50 by root, Thu Jul 12 19:36:58 2007 UTC vs.
Revision 1.51 by root, Sat Jul 28 00:15:03 2007 UTC

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
41// disconnect a socket after this many seconds without an ack 36// disconnect a socket after this many seconds without an ack
42#define SOCKET_TIMEOUT 8. 37#define SOCKET_TIMEOUT 8.
43 38
44// force a packet when idle for more than this many seconds, 39// force a packet when idle for more than this many seconds,
45// forcing an ack regularly. 40// forcing an ack regularly.
48void 43void
49client::flush () 44client::flush ()
50{ 45{
51 if (destroyed ()) 46 if (destroyed ())
52 return; 47 return;
53
54# if HAVE_SIOCOUTQ
55 {
56 int value;
57
58 if (!ioctl (fd, SIOCOUTQ, &value))
59 outq = value;
60 }
61# endif
62 48
63#if HAVE_TCP_INFO 49#if HAVE_TCP_INFO
64 // check about once per second, spread evenly over all clients 50 // check about once per second, spread evenly over all clients
65 // do this only when player is active 51 // do this only when player is active
66 if (!((pticks + fd) & 7) && pl && pl->active) 52 if (!((pticks + fd) & 7) && pl && pl->active)
67 { 53 {
68 // check time of last ack, and, if too old, kill connection 54 // check time of last ack, and, if too old, kill connection
69 struct tcp_info tcpi;
70 socklen_t len = sizeof (tcpi); 55 socklen_t len = sizeof (tcpi);
71 56
72 if (!getsockopt (fd, IPPROTO_TCP, TCP_INFO, &tcpi, &len) && len == sizeof (tcpi)) 57 if (!getsockopt (fd, IPPROTO_TCP, TCP_INFO, &tcpi, &len) && len == sizeof (tcpi))
73 { 58 {
74 if (tcpi.tcpi_snd_mss) 59 if (tcpi.tcpi_snd_mss)
75 mss = tcpi.tcpi_snd_mss; 60 mss = tcpi.tcpi_snd_mss;
76 61
77 rtt = tcpi.tcpi_rtt; 62 fprintf (stderr, "uack %d sst %d cwnd %d mss %d pmtu %d\n",
78 rttvar = tcpi.tcpi_rttvar; 63 tcpi.tcpi_unacked, tcpi.tcpi_snd_ssthresh, tcpi.tcpi_snd_cwnd, tcpi.tcpi_advmss, tcpi.tcpi_pmtu);
79 64
80 if (tcpi.tcpi_last_ack_recv > int (SOCKET_TIMEOUT * 1000)) 65 if (tcpi.tcpi_last_ack_recv > int (SOCKET_TIMEOUT * 1000))
81 { 66 {
82 send_msg (NDI_RED, "connection-timeout", "safety disconnect due to tcp/ip timeout (no packets received)"); 67 send_msg (NDI_RED, "connection-timeout", "safety disconnect due to tcp/ip timeout (no packets received)");
83 write_outputbuffer (); 68 write_outputbuffer ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines