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.44 by root, Sat Jun 9 22:54:28 2007 UTC vs.
Revision 1.46 by root, Sun Jun 10 04:44:21 2007 UTC

19 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
22 */ 22 */
23 23
24/**
25 * \file
26 * Low-level socket-related functions.
27 *
28 * \date 2003-12-02
29 *
30 * Contains some base functions that both the client and server
31 * can use. As such, depending what we are being compiled for will
32 * determine what we can include. the client is designed have
33 * CFCLIENT defined as part of its compile flags.
34 */
35
36using namespace std; 24using namespace std;
37 25
38#include <global.h> 26#include <global.h>
39#include <sproto.h> 27#include <sproto.h>
40#include <cstdarg> 28#include <cstdarg>
41 29
42#ifdef __linux__ 30#if HAVE_TCP_INFO
43# include <sys/types.h> 31# include <sys/types.h>
44# include <sys/socket.h> 32# include <sys/socket.h>
45# include <netinet/in.h> 33# include <netinet/in.h>
46# include <netinet/tcp.h> 34# include <netinet/tcp.h>
47#endif 35#endif
57client::flush () 45client::flush ()
58{ 46{
59 if (destroyed ()) 47 if (destroyed ())
60 return; 48 return;
61 49
62#ifdef __linux__ //TODO: this is available on bsds, too, use a configure test. 50#if HAVE_TCP_INFO
63 // check about once per second, spread evenly over all clients 51 // check about once per second, spread evenly over all clients
64 if (!((pticks + fd) & 7)) 52 if (!((pticks + fd) & 7))
65 { 53 {
66 // check time of last ack, and, if too old, kill connection 54 // check time of last ack, and, if too old, kill connection
67 struct tcp_info tcpi; 55 struct tcp_info tcpi;
68 socklen_t len = sizeof (tcpi); 56 socklen_t len = sizeof (tcpi);
69 57
70 if (!getsockopt (fd, IPPROTO_TCP, TCP_INFO, &tcpi, &len) && len == sizeof (tcpi)) 58 if (!getsockopt (fd, IPPROTO_TCP, TCP_INFO, &tcpi, &len) && len == sizeof (tcpi))
71 { 59 {
60 if (tcpi.tcpi_snd_mss)
61 mss = tcpi.tcpi_snd_mss;
62
72 rtt = tcpi.tcpi_rtt; 63 rtt = tcpi.tcpi_rtt;
73 rttvar = tcpi.tcpi_rttvar; 64 rttvar = tcpi.tcpi_rttvar;
74 65
75 if (tcpi.tcpi_last_ack_recv > int (SOCKET_TIMEOUT * 1000)) 66 if (tcpi.tcpi_last_ack_recv > int (SOCKET_TIMEOUT * 1000))
76 { 67 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines