Networking. More...
#include "global.hpp"#include "gettext.hpp"#include "log.hpp"#include "network_worker.hpp"#include "serialization/string_utils.hpp"#include "thread.hpp"#include "util.hpp"#include "config.hpp"#include "filesystem.hpp"#include <cerrno>#include <queue>#include <iomanip>#include <set>#include <cstring>#include <stdexcept>#include <signal.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <netinet/tcp.h>#include <fcntl.h>
Go to the source code of this file.
Classes | |
| struct | network::bandwidth_stats |
| struct | network::bandwidth_stats_output |
Namespaces | |
| namespace | network |
High level network layer for config object transport. | |
Defines | |
| #define | SOCKET int |
| #define | DBG_NW LOG_STREAM(debug, log_network) |
| #define | LOG_NW LOG_STREAM(info, log_network) |
| #define | WRN_NW LOG_STREAM(warn, log_network) |
| #define | ERR_NW LOG_STREAM(err, log_network) |
Typedefs | |
| typedef std::map< const std::string, bandwidth_stats > | network::bandwidth_map |
| typedef std::vector < bandwidth_map > | network::hour_stats_vector |
| typedef boost::shared_ptr < bandwidth_stats > | network::bandwidth_stats_ptr |
Functions | |
| static int | create_connection (TCPsocket sock, const std::string &host, int port) |
| static connection_details & | get_connection_details (network::connection handle) |
| static TCPsocket | get_socket (network::connection handle) |
| static void | remove_connection (network::connection handle) |
| static bool | is_pending_remote_handle (network::connection handle) |
| static void | set_remote_handle (network::connection handle, int remote_handle) |
| static void | check_error () |
| static void | check_timeout () |
| Check whether too much time since the last server ping has passed and we timed out. | |
| connection_stats | network::get_connection_stats (connection connection_num) |
| pending_statistics | network::get_pending_stats () |
| void | network::set_raw_data_only () |
| size_t | network::nconnections () |
| The number of peers we are connected to. | |
| bool | network::is_server () |
| If we are currently accepting connections. | |
| connection | network::connect (const std::string &host, int port=15000) |
| Function to attempt to connect to a remote host. | |
| connection | network::connect (const std::string &host, int port, threading::waiter &waiter) |
| connection | network::accept_connection () |
| Function to accept a connection from a remote host. | |
| bool | network::disconnect (connection connection_num=0) |
| Function to disconnect from a certain host, or close all connections if connection_num is 0. | |
| void | network::queue_disconnect (connection connection_num) |
| Function to queue a disconnection. | |
| connection | network::receive_data (config &cfg, connection connection_num, unsigned int timeout, bandwidth_in_ptr *bandwidth_in) |
| connection | network::receive_data (config &cfg, connection connection_num=0, bandwidth_in_ptr *b=0) |
| Function to receive data from either a certain connection, or all connections if connection_num is 0. | |
| connection | network::receive_data (std::vector< char > &buf, bandwidth_in_ptr *bandwidth_in) |
| hour_stats_vector | network::hour_stats (24) |
| static bandwidth_map::iterator | network::add_bandwidth_entry (const std::string &packet_type) |
| std::string | network::get_bandwidth_stats_all () |
| std::string | network::get_bandwidth_stats () |
| std::string | network::get_bandwidth_stats (int hour) |
| void | network::add_bandwidth_out (const std::string &packet_type, size_t len) |
| void | network::add_bandwidth_in (const std::string &packet_type, size_t len) |
| void | network::send_file (const std::string &filename, connection connection_num, const std::string &packet_type) |
| size_t | network::send_data (const config &cfg, connection connection_num=0, const std::string &packet_type="unknown") |
| Function to send data down a given connection, or broadcast to all peers if connection_num is 0. | |
| void | network::send_raw_data (const char *buf, int len, connection connection_num, const std::string &packet_type) |
| void | network::process_send_queue (connection connection_num=0, size_t max_size=0) |
| Function to send any data that is in a connection's send_queue, up to a maximum of 'max_size' bytes -- or the entire send queue if 'max_size' bytes is 0. | |
| void | network::send_data_all_except (const config &cfg, connection connection_num, const std::string &packet_type="unknown") |
| Function to send data to all peers except 'connection_num'. | |
| std::string | network::ip_address (connection connection_num) |
| Function to get the remote ip address of a socket. | |
| statistics | network::get_send_stats (connection handle) |
| Function to see the number of bytes being processed on the current socket. | |
| statistics | network::get_receive_stats (connection handle) |
Proxy Settings Methods | |
| void | network::enable_connection_through_proxy () |
| Attempt to connect through a proxy (as opposed to directly. | |
| void | network::set_proxy_address (const std::string &address) |
| Set the address of the proxy. | |
| void | network::set_proxy_port (const std::string &port) |
| Set the port of the proxy. | |
| void | network::set_proxy_user (const std::string &user) |
| Set the user to authenticate with the proxy. | |
| void | network::set_proxy_password (const std::string &password) |
| Set the password to authenticate with the proxy. | |
Variables | |
| static lg::log_domain | log_network ("network") |
| unsigned int | network::ping_timeout = 0 |
| Amount of seconds after the last server ping when we assume to have timed out. | |
Networking.
Definition in file network.cpp.
| #define DBG_NW LOG_STREAM(debug, log_network) |
Definition at line 61 of file network.cpp.
Referenced by check_timeout(), network::manager::manager(), and network::server_manager::server_manager().
| #define ERR_NW LOG_STREAM(err, log_network) |
Definition at line 64 of file network.cpp.
Referenced by check_timeout(), and network::manager::manager().
| #define LOG_NW LOG_STREAM(info, log_network) |
Definition at line 62 of file network.cpp.
Referenced by check_timeout().
| #define SOCKET int |
Definition at line 57 of file network.cpp.
| #define WRN_NW LOG_STREAM(warn, log_network) |
Definition at line 63 of file network.cpp.
| static void check_error | ( | ) | [static] |
Definition at line 136 of file network.cpp.
References _, network_worker_pool::detect_error(), and error().

| static void check_timeout | ( | ) | [static] |
Check whether too much time since the last server ping has passed and we timed out.
If the last check is too long ago reset the last_ping to 'now'. This happens when we "freeze" the client one way or another or we just didn't try to receive data.
Definition at line 154 of file network.cpp.
References DBG_NW, ERR_NW, error(), lexical_cast(), LOG_NW, network::nconnections(), network::ping_interval, and network::ping_timeout.

| static int create_connection | ( | TCPsocket | sock, | |
| const std::string & | host, | |||
| int | port | |||
| ) | [static] |
Definition at line 99 of file network.cpp.
| static connection_details& get_connection_details | ( | network::connection | handle | ) | [static] |
Definition at line 105 of file network.cpp.
Referenced by get_socket(), is_pending_remote_handle(), and set_remote_handle().


| static TCPsocket get_socket | ( | network::connection | handle | ) | [static] |
Definition at line 115 of file network.cpp.
References get_connection_details().
Referenced by network::server_manager::server_manager().


| static bool is_pending_remote_handle | ( | network::connection | handle | ) | [static] |
Definition at line 125 of file network.cpp.
References get_connection_details().

| static void remove_connection | ( | network::connection | handle | ) | [static] |
Definition at line 120 of file network.cpp.
Referenced by network::server_manager::stop().

| static void set_remote_handle | ( | network::connection | handle, | |
| int | remote_handle | |||
| ) | [static] |
Definition at line 131 of file network.cpp.
References get_connection_details().

| SOCKET channel |
Definition at line 386 of file network.cpp.
Referenced by sound::play_sound_internal().
Definition at line 373 of file network.cpp.
| std::string error_ |
Definition at line 372 of file network.cpp.
| std::string host_ |
Definition at line 370 of file network.cpp.
| IPaddress localAddress |
Definition at line 388 of file network.cpp.
lg::log_domain log_network("network") [static] |
| int port_ |
Definition at line 371 of file network.cpp.
| int ready |
Definition at line 385 of file network.cpp.
| IPaddress remoteAddress |
Definition at line 387 of file network.cpp.
| int sflag |
Definition at line 389 of file network.cpp.
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:08:35 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |