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

Comparing deliantra/server/socket/init.C (file contents):
Revision 1.18 by root, Thu Dec 14 21:46:34 2006 UTC vs.
Revision 1.20 by root, Fri Dec 15 19:59:20 2006 UTC

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>
52 46
53sockvec client_sockets; 47sockvec clients;
54 48
55/** 49/**
56 * Initializes a connection. Really, it just sets up the data structure, 50 * Initializes a connection. Really, it just sets up the data structure,
57 * socket setup is handled elsewhere. We do send a version to the 51 * socket setup is handled elsewhere. We do send a version to the
58 * client. 52 * client.
59 */ 53 */
60client_socket::client_socket (int fd, const char *peername) 54client::client (int fd, const char *peername)
61: fd (fd), host (strdup (peername)), 55: fd (fd), host (strdup (peername)),
62 socket_ev (this, &client_socket::socket_cb) 56 socket_ev (this, &client::socket_cb)
63{ 57{
64 { 58 {
65 struct linger linger_opt; 59 struct linger linger_opt;
66 60
67 linger_opt.l_onoff = 0; 61 linger_opt.l_onoff = 0;
124 if (socket_info.nconns > cst_tot.max_conn) cst_tot.max_conn = socket_info.nconns; 118 if (socket_info.nconns > cst_tot.max_conn) cst_tot.max_conn = socket_info.nconns;
125 if (socket_info.nconns > cst_lst.max_conn) cst_lst.max_conn = socket_info.nconns; 119 if (socket_info.nconns > cst_lst.max_conn) cst_lst.max_conn = socket_info.nconns;
126#endif 120#endif
127} 121}
128 122
129client_socket::~client_socket () 123client::~client ()
130{ 124{
131 status = Ns_Dead; 125 status = Ns_Dead;
132} 126}
133 127
134/** This sets up the socket and reads all the image information into memory. */ 128/** This sets up the socket and reads all the image information into memory. */
169 * might be associated with the socket. It is up to the caller to 163 * might be associated with the socket. It is up to the caller to
170 * update the list 164 * update the list
171 */ 165 */
172 166
173void 167void
174free_newsocket (client_socket *ns) 168free_newsocket (client *ns)
175{ 169{
176 if (ns->fd >= 0) 170 if (ns->fd >= 0)
177 close (ns->fd); 171 close (ns->fd);
178 172
179 if (ns->stats.range) 173 if (ns->stats.range)
198 free_newsocket (pl->socket); 192 free_newsocket (pl->socket);
199 free_player (pl); 193 free_player (pl);
200} 194}
201 195
202bool 196bool
203add_client_socket (int fd, const char *peername) 197add_client (int fd, const char *peername)
204{ 198{
205 if (checkbanned (NULL, peername)) 199 if (checkbanned (NULL, peername))
206 { 200 {
207 LOG (llevInfo, "Banned host tried to connect: [%s]\n", peername); 201 LOG (llevInfo, "Banned host tried to connect: [%s]\n", peername);
208 return false; 202 return false;
209 } 203 }
210 else 204 else
211 { 205 {
212 client_socket *ns = new client_socket (dup (fd), peername); 206 client *ns = new client (dup (fd), peername);
213 client_sockets.push_back (ns); 207 clients.push_back (ns);
214 return true; 208 return true;
215 } 209 }
216} 210}
217 211

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines