![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <fc_config.h>#include <cstring>#include <QCoreApplication>#include <QHostInfo>#include <QLocalServer>#include <QNetworkDatagram>#include <QTcpServer>#include <QTcpSocket>#include <QUdpSocket>#include "log.h"#include "shared.h"#include "support.h"#include "timing.h"#include "fc_version.h"#include "dataio.h"#include "events.h"#include "game.h"#include "packets.h"#include "script_server.h"#include "aiiface.h"#include "connecthand.h"#include "meta.h"#include "plrhand.h"#include "srv_main.h"#include "stdinhand.h"#include "unittools.h"#include "voting.h"#include "sernet.h"
Include dependency graph for sernet.cpp:Go to the source code of this file.
Classes | |
| struct | packet_to_handle |
Macros | |
| #define | PROCESSING_TIME_STATISTICS 0 |
Functions | |
| static void | start_processing_request (struct connection *pconn, int request_id) |
| Starts processing of request packet from client. More... | |
| static void | finish_processing_request (struct connection *pconn) |
| Finish processing of request packet from client. More... | |
| static void | send_lanserver_response () |
| This function broadcasts an UDP packet to clients with that requests information about the server state. More... | |
| static void | close_connection (struct connection *pconn) |
| Close the connection (very low-level). More... | |
| void | close_connections_and_socket () |
| Close all network stuff: connections, listening sockets, metaserver connection... More... | |
| void | really_close_connections () |
| Now really close connections marked as 'is_closing'. More... | |
| static void | server_conn_close_callback (struct connection *pconn) |
| Break a client connection. More... | |
| void | flush_packets () |
| Attempt to flush all information in the send buffers for upto 'netwait' seconds. More... | |
| static bool | get_packet (struct connection *pconn, struct packet_to_handle *ppacket) |
| Simplify a loop by wrapping get_packet_from_connection. More... | |
| void | incoming_client_packets (struct connection *pconn) |
| Handle all incoming packets on a client connection. More... | |
| static const char * | makeup_connection_name (int *id) |
| Make up a name for the connection, before we get any data from it to use as a sensible name. More... | |
| int | server_make_connection (QIODevice *new_sock, const QString &client_addr, const QString &ip_addr) |
| Server accepts connection from client: Low level socket stuff, and basic-initialize the connection struct. More... | |
| std::optional< socket_server > | server_open_socket () |
| Open server socket to be used to accept client connections and open a server socket for server LAN announcements. More... | |
| void | init_connections () |
| Initialize connection related stuff. More... | |
| void | finish_unit_waits () |
| Process all unit waits that are expired. More... | |
| void | connection_ping (struct connection *pconn) |
| Ping a connection. More... | |
| void | handle_conn_pong (struct connection *pconn) |
| Handle response to ping. More... | |
| void | handle_client_heartbeat (struct connection *pconn) |
| Handle client's regular hearbeat. More... | |
| void | get_lanserver_announcement () |
| Listen for UDP packets multicasted from clients requesting announcement of servers on the LAN. More... | |
Variables | |
| static struct connection | connections [MAX_NUM_CONNECTIONS] |
| static QUdpSocket * | udp_socket = nullptr |
| #define PROCESSING_TIME_STATISTICS 0 |
Definition at line 61 of file sernet.cpp.
|
static |
Close the connection (very low-level).
See also server_conn_close_callback().
Definition at line 73 of file sernet.cpp.
Referenced by close_connections_and_socket(), and really_close_connections().
| void close_connections_and_socket | ( | ) |
Close all network stuff: connections, listening sockets, metaserver connection...
Definition at line 106 of file sernet.cpp.
Referenced by server_quit().
| void connection_ping | ( | struct connection * | pconn | ) |
Ping a connection.
Definition at line 527 of file sernet.cpp.
Referenced by freeciv::server::send_pings().
|
static |
Finish processing of request packet from client.
Definition at line 487 of file sernet.cpp.
Referenced by incoming_client_packets().
| void finish_unit_waits | ( | ) |
Process all unit waits that are expired.
Definition at line 503 of file sernet.cpp.
Referenced by freeciv::server::pulse().
| void flush_packets | ( | ) |
Attempt to flush all information in the send buffers for upto 'netwait' seconds.
Definition at line 187 of file sernet.cpp.
Referenced by begin_phase(), dai_do_first_activities(), end_phase(), send_all_known_cities(), send_all_known_tiles(), and send_all_known_units().
| void get_lanserver_announcement | ( | ) |
Listen for UDP packets multicasted from clients requesting announcement of servers on the LAN.
Definition at line 572 of file sernet.cpp.
Referenced by freeciv::server::pulse().
|
static |
Simplify a loop by wrapping get_packet_from_connection.
Definition at line 216 of file sernet.cpp.
Referenced by incoming_client_packets().
| void handle_client_heartbeat | ( | struct connection * | pconn | ) |
Handle client's regular hearbeat.
Definition at line 563 of file sernet.cpp.
| void handle_conn_pong | ( | struct connection * | pconn | ) |
Handle response to ping.
Definition at line 541 of file sernet.cpp.
Referenced by server_packet_input().
| void incoming_client_packets | ( | struct connection * | pconn | ) |
Handle all incoming packets on a client connection.
Precondition - we have read_socket_data. Postcondition - there are no more packets to handle on this connection.
Definition at line 229 of file sernet.cpp.
Referenced by freeciv::server::input_on_socket().
| void init_connections | ( | ) |
Initialize connection related stuff.
Attention: Logging is not available within this functions!
Definition at line 452 of file sernet.cpp.
Referenced by main().
|
static |
Make up a name for the connection, before we get any data from it to use as a sensible name.
Name will be 'c' + integer, guaranteed not to be the same as any other connection name, nor player name nor user name, nor connection id (avoid possible confusions). Returns pointer to static buffer, and fills in (*id) with chosen value.
Definition at line 285 of file sernet.cpp.
Referenced by server_make_connection().
| void really_close_connections | ( | ) |
Now really close connections marked as 'is_closing'.
Do this here to avoid recursive sending.
Definition at line 140 of file sernet.cpp.
Referenced by freeciv::server::error_on_socket(), and freeciv::server::input_on_socket().
|
static |
This function broadcasts an UDP packet to clients with that requests information about the server state.
Definition at line 600 of file sernet.cpp.
Referenced by get_lanserver_announcement().
|
static |
Break a client connection.
You should almost always use connection_close_server() instead of calling this function directly.
Definition at line 177 of file sernet.cpp.
Referenced by server_open_socket().
| int server_make_connection | ( | QIODevice * | new_sock, |
| const QString & | client_addr, | ||
| const QString & | ip_addr | ||
| ) |
Server accepts connection from client: Low level socket stuff, and basic-initialize the connection struct.
Returns 0 on success, -1 on failure (bad accept(), or too many connections).
Definition at line 310 of file sernet.cpp.
Referenced by freeciv::server::accept_local_connections(), and freeciv::server::accept_tcp_connections().
| std::optional<socket_server> server_open_socket | ( | ) |
Open server socket to be used to accept client connections and open a server socket for server LAN announcements.
Definition at line 370 of file sernet.cpp.
|
static |
Starts processing of request packet from client.
Definition at line 472 of file sernet.cpp.
Referenced by incoming_client_packets().
|
static |
Definition at line 1 of file sernet.cpp.
Referenced by clear_worker_task(), close_connections_and_socket(), flush_packets(), handle_conn_ping_info(), init_connections(), package_and_send_worker_tasks(), really_close_connections(), and server_make_connection().
|
static |
Definition at line 59 of file sernet.cpp.
Referenced by close_connections_and_socket(), get_lanserver_announcement(), and server_open_socket().