Freeciv21
Develop your civilization from humble roots to a global empire
sernet.h File Reference
#include <memory>
#include <optional>
#include <variant>
+ Include dependency graph for sernet.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BUF_SIZE   512
 
#define SERVER_LAN_PORT   4555
 
#define SERVER_LAN_TTL   1
 
#define SERVER_LAN_VERSION   2
 

Typedefs

using socket_server = std::variant< std::unique_ptr< QTcpServer >, std::unique_ptr< QLocalServer > >
 

Functions

std::optional< socket_serverserver_open_socket ()
 Open server socket to be used to accept client connections and open a server socket for server LAN announcements. More...
 
void flush_packets ()
 Attempt to flush all information in the send buffers for upto 'netwait' seconds. More...
 
void incoming_client_packets (connection *pconn)
 Handle all incoming packets on a client connection. 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...
 
void init_connections ()
 Initialize connection related stuff. 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...
 
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...
 

Macro Definition Documentation

◆ BUF_SIZE

#define BUF_SIZE   512

Definition at line 25 of file sernet.h.

◆ SERVER_LAN_PORT

#define SERVER_LAN_PORT   4555

Definition at line 27 of file sernet.h.

◆ SERVER_LAN_TTL

#define SERVER_LAN_TTL   1

Definition at line 28 of file sernet.h.

◆ SERVER_LAN_VERSION

#define SERVER_LAN_VERSION   2

Definition at line 29 of file sernet.h.

Typedef Documentation

◆ socket_server

using socket_server = std::variant<std::unique_ptr<QTcpServer>, std::unique_ptr<QLocalServer> >

Definition at line 31 of file sernet.h.

Function Documentation

◆ close_connections_and_socket()

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().

◆ connection_ping()

void connection_ping ( struct connection pconn)

Ping a connection.

Definition at line 527 of file sernet.cpp.

Referenced by freeciv::server::send_pings().

◆ finish_unit_waits()

void finish_unit_waits ( )

Process all unit waits that are expired.

Definition at line 503 of file sernet.cpp.

Referenced by freeciv::server::pulse().

◆ flush_packets()

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().

◆ get_lanserver_announcement()

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().

◆ handle_client_heartbeat()

void handle_client_heartbeat ( struct connection pconn)

Handle client's regular hearbeat.

Definition at line 563 of file sernet.cpp.

◆ handle_conn_pong()

void handle_conn_pong ( struct connection pconn)

Handle response to ping.

Definition at line 541 of file sernet.cpp.

Referenced by server_packet_input().

◆ incoming_client_packets()

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().

◆ init_connections()

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().

◆ really_close_connections()

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().

◆ server_make_connection()

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().

◆ server_open_socket()

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.