Crossfire Server, Trunk  R20513
Functions | Variables
init.c File Reference

Socket general functions. More...

#include "global.h"
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netdb.h>
#include "image.h"
#include "newserver.h"
#include "sproto.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

void final_free_player (player *pl)
 Sends the 'goodbye' command to the player, and closes connection. More...
 
void free_all_newserver (void)
 Free's all the memory that ericserver allocates. More...
 
void free_newsocket (socket_struct *ns)
 Frees a socket. More...
 
void init_connection (socket_struct *ns, const char *from_ip)
 Initializes a connection. More...
 
void init_listening_socket (socket_struct *ns)
 This opens *ns for listening to connections. More...
 
void init_server (void)
 This sets up the socket and reads all the image information into memory. More...
 

Variables

socket_structinit_sockets
 Established connections for clients not yet playing. More...
 
Socket_Info socket_info
 Socket information. More...
 

Detailed Description

Socket general functions.

Date
2003-12-02

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 ericserver.c

Definition in file init.c.

Function Documentation

void final_free_player ( player pl)

Sends the 'goodbye' command to the player, and closes connection.

Definition at line 444 of file init.c.

References free_newsocket(), free_player(), Send_With_Handling(), pl::socket, SockList_AddString(), SockList_Init(), and SockList_Term().

Referenced by check_login(), and do_server().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_all_newserver ( void  )

Free's all the memory that ericserver allocates.

Definition at line 395 of file init.c.

References Socket_Info::allocated_sockets, free_socket_images(), socket_struct::listen, llevDebug, and LOG().

Referenced by cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

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 413 of file init.c.

References account_char_free(), account_char_save(), socket_struct::account_chars, socket_struct::account_name, socket_struct::fd, FREE_AND_CLEAR, 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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 63 of file init.c.

References socket_struct::account_chars, socket_struct::account_name, Socket_Info::allocated_sockets, socket_struct::anims_sent, SockList::buf, socket_struct::can_write, 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, socket_struct::heartbeat, socket_struct::host, socket_struct::inbuf, socket_struct::is_bot, socket_struct::lastmap, buffer_struct::len, llevDebug, llevError, LOG(), socket_struct::login_method, socket_struct::look_position, 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, nrofpixmaps, Ns_Add, NS_FACESENT_FACE, socket_struct::num_look_objects, socket_struct::outputbuffer, socket_struct::password_fails, Send_With_Handling(), socklen_t, SockList_AddPrintf(), SockList_Init(), SockList_ResetRead(), SockList_Term(), socket_struct::sound, socket_struct::sounds_this_tick, buffer_struct::start, socket_struct::stats, socket_struct::status, strdup_local, 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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 171 of file init.c.

References listen_info::addr, listen_info::addrlen, listen_info::family, fatal(), socket_struct::fd, socket_struct::listen, llevError, LOG(), MAX_BUF, Ns_Add, Ns_Dead, listen_info::protocol, SEE_LAST_ERROR, snprintf, listen_info::socktype, and socket_struct::status.

Referenced by do_server(), and init_server().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_server ( void  )

This sets up the socket and reads all the image information into memory.

Todo:
fix socket_info.max_filedescriptor hack.

Definition at line 262 of file init.c.

References socket_struct::account_name, listen_info::addr, listen_info::addrlen, Socket_Info::allocated_sockets, Settings::csport, cst_lst, cst_tot, socket_struct::faces_sent, listen_info::family, fatal(), init_listening_socket(), socket_struct::listen, llevDebug, llevError, LOG(), MAX_BUF, Socket_Info::max_filedescriptor, listen_info::protocol, read_client_images(), SEE_LAST_ERROR, settings, snprintf, listen_info::socktype, CS_Stats::time_start, and Socket_Info::timeout.

Referenced by init().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

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.

Definition at line 56 of file init.c.

Referenced by account_get_logged_in_init_socket(), block_until_new_connection(), do_server(), and new_connection().

Socket_Info socket_info

Socket information.

Definition at line 47 of file init.c.

Referenced by account_get_logged_in_init_socket(), block_until_new_connection(), do_server(), new_connection(), and Send_With_Handling().