Crossfire Server, Trunk
|
#include "global.h"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include "image.h"
#include "newserver.h"
#include "sproto.h"
Go to the source code of this file.
Typedefs | |
typedef int | ssop_t |
Functions | |
void | final_free_player (player *pl) |
void | free_all_newserver (void) |
void | free_newsocket (socket_struct *ns) |
void | init_connection (socket_struct *ns, const char *from_ip) |
void | init_listening_socket (socket_struct *ns) |
void | init_server (void) |
static void | set_output_sock_buf (socket_struct *ns, int bufsize) |
Variables | |
socket_struct * | init_sockets |
Socket_Info | socket_info |
Socket general functions
Mainly deals with initialization and higher level socket maintenance (checking for lost connections and if data has arrived.) The reading of data is handled in loop.c
Definition in file init.cpp.
typedef int ssop_t |
void final_free_player | ( | player * | pl | ) |
Sends the 'goodbye' command to the player, and closes connection.
Definition at line 453 of file init.cpp.
References free_newsocket(), free_player(), altar_valkyrie::pl, Send_With_Handling(), SockList_AddString(), SockList_Init(), and SockList_Term().
Referenced by check_login(), do_server(), and save_and_kick_all_players().
void free_all_newserver | ( | void | ) |
Free's all the memory that ericserver allocates.
Definition at line 401 of file init.cpp.
References Socket_Info::allocated_sockets, init_sockets, socket_struct::listen, llevDebug, LOG(), and socket_info.
Referenced by cleanup().
void free_newsocket | ( | socket_struct * | ns | ) |
Frees a socket. Basically, all we need to do here is free all data structures that might be associated with the socket. It is up to the caller to update the list
Definition at line 418 of file init.cpp.
References account_char_free(), account_char_save(), socket_struct::account_chars, account_logout(), socket_struct::account_name, socket_struct::faces_sent, socket_struct::fd, FREE_AND_CLEAR, statsinfo::god, socket_struct::host, socket_struct::inbuf, llevDebug, LOG(), statsinfo::range, SockList_Term(), socket_struct::stats, and statsinfo::title.
Referenced by do_server(), and final_free_player().
void init_connection | ( | socket_struct * | ns, |
const char * | from_ip | ||
) |
Initializes a connection. Really, it just sets up the data structure, socket setup is handled elsewhere. We do send a version to the client.
Definition at line 96 of file init.cpp.
References account_char_free(), socket_struct::account_chars, socket_struct::account_name, Socket_Info::allocated_sockets, socket_struct::anims_sent, SockList::buf, socket_struct::container_position, cst_lst, cst_tot, socket_struct::darkness, DEFAULT_NUM_LOOK_OBJECTS, socket_struct::extended_stats, socket_struct::facecache, socket_struct::faces_sent, socket_struct::faces_sent_len, socket_struct::faceset, socket_struct::fd, FREE_AND_CLEAR, get_faces_count(), socket_struct::heartbeat, socket_struct::host, socket_struct::inbuf, socket_struct::is_bot, socket_struct::lastmap, llevError, LOG(), socket_struct::login_method, socket_struct::look_position, MAP_CLIENT_X_DEFAULT, MAP_CLIENT_Y_DEFAULT, socket_struct::map_scroll_x, socket_struct::map_scroll_y, socket_struct::mapx, socket_struct::mapy, CS_Stats::max_conn, socket_struct::monitor_spells, socket_struct::notifications, Ns_Add, NS_FACESENT_FACE, socket_struct::num_look_objects, socket_struct::password_fails, Send_With_Handling(), set_output_sock_buf(), socket_info, SOCKETBUFSIZE, SockList_AddPrintf(), SockList_Init(), SockList_ResetRead(), SockList_Term(), socket_struct::sound, socket_struct::sounds_this_tick, socket_struct::stats, socket_struct::status, strdup_local, guildbuy::temp, socket_struct::tick, socket_struct::update_inventory, socket_struct::update_look, VERSION_CS, VERSION_INFO, VERSION_SC, and socket_struct::want_pickup.
Referenced by new_connection().
void init_listening_socket | ( | socket_struct * | ns | ) |
This opens *ns for listening to connections. The structure must be allocated already and ns->listen must be initialized. No other variable is changed.
Definition at line 192 of file init.cpp.
References listen_info::addr, listen_info::addrlen, listen_info::family, fatal(), socket_struct::fd, log_login::ip, socket_struct::listen, llevError, LOG(), MAX_BUF, Ns_Add, Ns_Dead, listen_info::protocol, SEE_LAST_ERROR, listen_info::socktype, socket_struct::status, and Ice::tmp.
Referenced by do_server(), and init_server().
void init_server | ( | void | ) |
This sets up the listening socket.
Definition at line 283 of file init.cpp.
References socket_struct::account_name, listen_info::addr, listen_info::addrlen, Socket_Info::allocated_sockets, buf, Settings::csport, cst_lst, cst_tot, socket_struct::faces_sent, listen_info::family, fatal(), init_listening_socket(), init_sockets, socket_struct::listen, llevDebug, llevError, LOG(), MAX_BUF, Socket_Info::max_filedescriptor, MIN, listen_info::protocol, reset_stats(), SEE_LAST_ERROR, settings, socket_info, listen_info::socktype, and Socket_Info::timeout.
Referenced by init().
|
static |
Definition at line 68 of file init.cpp.
References socket_struct::fd, llevDebug, llevError, LOG(), socklen_t, and Ice::tmp.
Referenced by init_connection().
socket_struct* init_sockets |
Established connections for clients not yet playing. See the page on the login process for a description of its use. Socket at index 0 is the socket listening for connections, and must not be freed. If this socket becomes invalid, then the server will try to reopen it. We also take the opportunity to set TCP_NODELAY - this forces the data in the socket to be flushed sooner to the client - otherwise, the OS tries to wait for full packets and will this hold sending the data for some amount of time, which thus adds some additional latency.
Definition at line 66 of file init.cpp.
Referenced by check_all_fds(), do_server(), free_all_newserver(), init_server(), and new_connection().
Socket_Info socket_info |
Socket information.
Definition at line 52 of file init.cpp.
Referenced by check_all_fds(), command_recollect(), do_server(), free_all_newserver(), init_connection(), init_server(), and new_connection().