Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
servers.h File Reference
#include "fcthread.h"
#include "speclist.h"

Go to the source code of this file.

Data Structures

struct  server
 
struct  server::players
 
struct  srv_list
 

Macros

#define SERVER_LAN_PORT   4555
 
#define SERVER_LAN_TTL   1
 
#define SERVER_LAN_VERSION   2
 
#define SPECLIST_TAG   server
 
#define SPECLIST_TYPE   struct server
 
#define server_list_iterate(serverlist, pserver)    TYPED_LIST_ITERATE(struct server, serverlist, pserver)
 
#define server_list_iterate_end   LIST_ITERATE_END
 

Typedefs

typedef void(* ServerScanErrorFunc) (struct server_scan *scan, const char *message)
 

Enumerations

enum  server_scan_type { SERVER_SCAN_LOCAL , SERVER_SCAN_GLOBAL , SERVER_SCAN_LAST }
 
enum  server_scan_status {
  SCAN_STATUS_ERROR = 0 , SCAN_STATUS_WAITING , SCAN_STATUS_PARTIAL , SCAN_STATUS_DONE ,
  SCAN_STATUS_ABORT
}
 

Functions

struct server_scanserver_scan_begin (enum server_scan_type type, ServerScanErrorFunc error_func)
 
enum server_scan_type server_scan_get_type (const struct server_scan *scan)
 
enum server_scan_status server_scan_poll (struct server_scan *scan)
 
struct srv_listserver_scan_get_list (struct server_scan *scan)
 
void server_scan_finish (struct server_scan *scan)
 

Macro Definition Documentation

◆ SERVER_LAN_PORT

#define SERVER_LAN_PORT   4555

Definition at line 24 of file servers.h.

◆ SERVER_LAN_TTL

#define SERVER_LAN_TTL   1

Definition at line 25 of file servers.h.

◆ SERVER_LAN_VERSION

#define SERVER_LAN_VERSION   2

Definition at line 26 of file servers.h.

◆ server_list_iterate

#define server_list_iterate (   serverlist,
  pserver 
)     TYPED_LIST_ITERATE(struct server, serverlist, pserver)

Definition at line 55 of file servers.h.

◆ server_list_iterate_end

#define server_list_iterate_end   LIST_ITERATE_END

Definition at line 57 of file servers.h.

◆ SPECLIST_TAG

#define SPECLIST_TAG   server

Definition at line 51 of file servers.h.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct server

Definition at line 52 of file servers.h.

Typedef Documentation

◆ ServerScanErrorFunc

typedef void(* ServerScanErrorFunc) (struct server_scan *scan, const char *message)

Definition at line 73 of file servers.h.

Enumeration Type Documentation

◆ server_scan_status

Enumerator
SCAN_STATUS_ERROR 
SCAN_STATUS_WAITING 
SCAN_STATUS_PARTIAL 
SCAN_STATUS_DONE 
SCAN_STATUS_ABORT 

Definition at line 79 of file servers.h.

◆ server_scan_type

Enumerator
SERVER_SCAN_LOCAL 
SERVER_SCAN_GLOBAL 
SERVER_SCAN_LAST 

Definition at line 67 of file servers.h.

Function Documentation

◆ server_scan_begin()

struct server_scan * server_scan_begin ( enum server_scan_type  type,
ServerScanErrorFunc  error_func 
)

Creates a new server scan and returns it, or NULL if impossible.

Depending on 'type' the scan will look for either local or internet games.

error_func provides a callback to be used in case of error; this callback probably should call server_scan_finish.

NB: You must call server_scan_finish() when you are done with the scan to free the memory and resources allocated by it.

Definition at line 755 of file servers.c.

Referenced by sdl_create_server_list(), fc_client::update_network_lists(), and update_network_lists().

◆ server_scan_finish()

void server_scan_finish ( struct server_scan scan)

Closes the socket listening on the scan, frees the list of servers, and frees the memory allocated for 'scan' by server_scan_begin().

Definition at line 879 of file servers.c.

Referenced by close_connection_dialog(), destroy_server_scans(), fc_client::destroy_server_scans(), exit_meta_server_dlg_callback(), server_scan_begin(), and server_scan_error().

◆ server_scan_get_list()

struct srv_list * server_scan_get_list ( struct server_scan scan)

Returns the srv_list currently held by the scan (may be NULL).

Definition at line 866 of file servers.c.

Referenced by check_server_scan(), fc_client::check_server_scan(), network_list_callback(), sdl_create_server_list(), and fc_client::slot_selection_changed().

◆ server_scan_get_type()

enum server_scan_type server_scan_get_type ( const struct server_scan scan)

A simple query function to determine the type of a server scan (previously allocated in server_scan_begin).

Definition at line 809 of file servers.c.

Referenced by check_server_scan(), fc_client::check_server_scan(), and server_scan_error().

◆ server_scan_poll()

enum server_scan_status server_scan_poll ( struct server_scan scan)

A function to query servers of the server scan. This will check any pending network data and update the server list.

The return value indicates the status of the server scan: SCAN_STATUS_ERROR - The scan failed and should be aborted. SCAN_STATUS_WAITING - The scan is in progress (continue polling). SCAN_STATUS_PARTIAL - The scan received some data, with more expected. Get the servers with server_scan_get_list(), and continue polling. SCAN_STATUS_DONE - The scan received all data it expected to receive. Get the servers with server_scan_get_list(), and stop calling this function. SCAN_STATUS_ABORT - The scan has been aborted

Definition at line 832 of file servers.c.

Referenced by check_server_scan(), fc_client::check_server_scan(), and sdl_create_server_list().