Freeciv-3.2
|
#include "fc_prehdrs.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "capstr.h"
#include "dataio.h"
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "netintf.h"
#include "registry.h"
#include "support.h"
#include "game.h"
#include "packets.h"
#include "version.h"
#include "agents.h"
#include "attribute.h"
#include "audio.h"
#include "chatline_g.h"
#include "client_main.h"
#include "climisc.h"
#include "connectdlg_common.h"
#include "connectdlg_g.h"
#include "dialogs_g.h"
#include "gui_main_g.h"
#include "mapview_common.h"
#include "menu_g.h"
#include "messagewin_g.h"
#include "options.h"
#include "packhand.h"
#include "pages_g.h"
#include "plrdlg_g.h"
#include "repodlgs_g.h"
#include "clinet.h"
Go to the source code of this file.
Macros | |
#define | AUTOCONNECT_INTERVAL 500 |
#define | MAX_AUTOCONNECT_ATTEMPTS 100 |
Functions | |
static void | close_socket_nomessage (struct connection *pc) |
static void | client_conn_close_callback (struct connection *pconn) |
static int | get_server_address (const char *hostname, int port, char *errbuf, int errbufsize) |
static int | try_to_connect (const char *username, char *errbuf, int errbufsize) |
int | connect_to_server (const char *username, const char *hostname, int port, char *errbuf, int errbufsize) |
void | make_connection (int sock, const char *username) |
void | disconnect_from_server (bool leaving_sound) |
static int | read_from_connection (struct connection *pc, bool block) |
void | input_from_server (int fd) |
void | input_from_server_till_request_got_processed (int fd, int expected_request_id) |
double | try_to_autoconnect (void) |
void | start_autoconnecting_to_server (void) |
Variables | |
static struct fc_sockaddr_list * | list = NULL |
static bool | autoconnecting = FALSE |
|
static |
Client connection close socket callback. It shouldn't be called directy. Use connection_close() instead.
Definition at line 122 of file clinet.c.
Referenced by try_to_connect().
|
static |
Close socket and cleanup. This one doesn't print a message, so should do so before-hand if necessary.
Definition at line 108 of file clinet.c.
Referenced by client_conn_close_callback(), and disconnect_from_server().
int connect_to_server | ( | const char * | username, |
const char * | hostname, | ||
int | port, | ||
char * | errbuf, | ||
int | errbufsize | ||
) |
Connect to a freeciv-server instance – or at least try to. On success, return 0; on failure, put an error message in ERRBUF and return -1.
Definition at line 249 of file clinet.c.
Referenced by client_start_server(), connect_callback(), connect_callback(), and fc_client::slot_connect().
Get rid of server connection. This also kills internal server if it's used.
Definition at line 306 of file clinet.c.
Referenced by mr_menu::back_to_menu(), cancel_passwd_callback(), client_packet_input(), disconnect_callback(), disconnect_conn_callback(), exit_callback(), leave_callback(), leave_callback(), leave_local_game_response(), main_callback(), popup_quit_dialog(), quit_dialog_response(), fc_client::slot_disconnect(), and fc_client::switch_page().
|
static |
Get ready to [try to] connect to a server:
Definition at line 148 of file clinet.c.
Referenced by connect_to_server(), and start_autoconnecting_to_server().
This function is called when the client received a new input from the server.
Definition at line 411 of file clinet.c.
Referenced by get_net_input(), gui_event_loop(), gui_event_loop(), and fc_client::server_input().
This function will sniff at the given fd, get the packet and call client_packet_input. It will return if there is a network error or if the PACKET_PROCESSING_FINISHED packet for the given request is received.
Definition at line 447 of file clinet.c.
Referenced by wait_till_request_got_processed().
Called after a connection is completed (e.g., in try_to_connect).
Definition at line 275 of file clinet.c.
Referenced by try_to_connect().
|
static |
A wrapper around read_socket_data() which also handles the case the socket becomes writeable and there is still data which should be sent to the server.
Returns: -1 : an error occurred - you should close the socket -2 : the connection was closed >0 : number of bytes read =0 : no data read, would block
Definition at line 345 of file clinet.c.
Referenced by input_from_server(), and input_from_server_till_request_got_processed().
Start trying to autoconnect to freeciv-server. Calls get_server_address(), then arranges for try_to_autoconnect(), which calls try_to_connect(), to be called roughly every AUTOCONNECT_INTERVAL milliseconds, until success, fatal error or user intervention.
Definition at line 553 of file clinet.c.
Referenced by set_client_state().
Make an attempt to autoconnect to the server. It returns number of seconds it should be called again.
Definition at line 498 of file clinet.c.
Referenced by gui_event_loop(), gui_event_loop(), and real_timer_callback().
Try to connect to a server (get_server_address() must be called first!):
Definition at line 194 of file clinet.c.
Referenced by connect_to_server(), and try_to_autoconnect().
Definition at line 493 of file clinet.c.
Referenced by start_autoconnecting_to_server(), and try_to_autoconnect().
|
static |
Definition at line 102 of file clinet.c.
Referenced by combat_bonus_against(), create_list_of_nations_in_group(), create_races_dialog(), create_worklists_report(), city_dialog::display_worklist_menu(), city_widget::gen_cma_labels(), city_widget::gen_production_labels(), city_widget::gen_worklist_labels(), get_server_address(), get_theme_list(), get_tileset_list(), gui_dialog_set_default_response(), gui_dialog_set_response_sensitive(), gui_dialog_show_all(), helptext_extra(), helptext_nation(), helptext_terrain(), helptext_unit(), is_on_allowed_list(), lookup_cbonus_list(), menu_remove_previous_entries(), move_toolkit(), non_allied_not_listed_at(), option_dialog_option_add(), path_to_nation_on_list(), popup_info_text(), races_toggles_set_sensitive(), real_menus_init(), real_menus_update(), req_text_insert(), sdl_create_server_list(), select_nation_on_tab(), server_open_socket(), help_widget::set_topic_unit(), themespec_try_read(), tilespec_try_read(), try_to_connect(), unit_activity_handling_targeted(), update_server_list(), fc_client::update_server_list(), update_source_label(), waiting_queue_add_pending_request(), and waiting_queue_execute_pending_requests().