… | |
… | |
39 | #include <sys/time.h> |
39 | #include <sys/time.h> |
40 | #include <sys/socket.h> |
40 | #include <sys/socket.h> |
41 | #include <netinet/in.h> |
41 | #include <netinet/in.h> |
42 | #include <netdb.h> |
42 | #include <netdb.h> |
43 | |
43 | |
44 | #ifdef HAVE_UNISTD_H |
|
|
45 | # include <unistd.h> |
44 | #include <unistd.h> |
46 | #endif |
|
|
47 | |
|
|
48 | #ifdef HAVE_ARPA_INET_H |
|
|
49 | # include <arpa/inet.h> |
45 | #include <arpa/inet.h> |
50 | #endif |
|
|
51 | #include <newserver.h> |
46 | #include <newserver.h> |
52 | |
47 | |
53 | sockvec client_sockets; |
48 | sockvec client_sockets; |
54 | |
49 | |
55 | /** |
50 | /** |
56 | * Initializes a connection. Really, it just sets up the data structure, |
51 | * Initializes a connection. Really, it just sets up the data structure, |
57 | * socket setup is handled elsewhere. We do send a version to the |
52 | * socket setup is handled elsewhere. We do send a version to the |
58 | * client. |
53 | * client. |
59 | */ |
54 | */ |
60 | client_socket::client_socket (int fd, const char *peername) |
55 | client_socket::client_socket (int fd, const char *peername) |
61 | : fd (fd), host (strdup (peername)) |
56 | : fd (fd), host (strdup (peername)), |
|
|
57 | socket_ev (this, &client_socket::socket_cb) |
62 | { |
58 | { |
63 | { |
59 | { |
64 | struct linger linger_opt; |
60 | struct linger linger_opt; |
65 | |
61 | |
66 | linger_opt.l_onoff = 0; |
62 | linger_opt.l_onoff = 0; |
… | |
… | |
105 | * this face. Face 0 is sent to the client to say clear |
101 | * this face. Face 0 is sent to the client to say clear |
106 | * face information. |
102 | * face information. |
107 | */ |
103 | */ |
108 | faces_sent[0] = NS_FACESENT_FACE; |
104 | faces_sent[0] = NS_FACESENT_FACE; |
109 | |
105 | |
110 | can_write = 1; |
106 | socket_ev.fd (fd); |
111 | |
107 | |
112 | // initialisation done, kick it! |
108 | // initialisation done, kick it! |
113 | |
109 | |
114 | { |
110 | { |
115 | packet sl; |
111 | packet sl; |
116 | sl.printf ("version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO); |
112 | sl.printf ("version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO); |
117 | send_packet (sl); |
113 | send_packet (sl); |
|
|
114 | flush (); |
118 | } |
115 | } |
119 | |
116 | |
120 | #if 0//TODO |
117 | #if 0//TODO |
121 | socket_info.nconns++; |
118 | socket_info.nconns++; |
122 | if (socket_info.nconns > cst_tot.max_conn) cst_tot.max_conn = socket_info.nconns; |
119 | if (socket_info.nconns > cst_tot.max_conn) cst_tot.max_conn = socket_info.nconns; |