Data Structures | Defines | Typedefs | Functions | Variables

# network_server.h File Reference

Server part of the network protocol. More...

`#include "network_internal.h"`
`#include "core/tcp_listen.h"`
`#include "../thread/thread.h"`

Go to the source code of this file.

## Data Structures
class | ServerNetworkGameSocketHandler
| Class for handling the server side of the game connection. More...
## Defines
#define | FOR_ALL_CLIENT_SOCKETS_FROM(var, start) FOR_ALL_ITEMS_FROM(NetworkClientSocket, clientsocket_index, var, start)
| Iterate over all the sockets from a given starting point.
#define | FOR_ALL_CLIENT_SOCKETS(var) FOR_ALL_CLIENT_SOCKETS_FROM(var, 0)
| Iterate over all the sockets.
## Typedefs
typedef ServerNetworkGameSocketHandler | NetworkClientSocket
| Make the code look slightliy nicer/simpler.
typedef Pool < NetworkClientSocket, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT > | NetworkClientSocketPool
| Pool with all client sockets.
## Functions
void | NetworkServer_Tick (bool send_frame)
| This is called every tick if this is a _network_server.
void | NetworkServerSetCompanyPassword (CompanyID company_id, const char *password, bool already_hashed=true)
| Set/Reset a company password on the server end.
## Variables
NetworkClientSocketPool | _networkclientsocket_pool
| The pool with clients.

## Detailed Description

Server part of the network protocol.

Definition in file network_server.h.

## Define Documentation

#define FOR_ALL_CLIENT_SOCKETS | ( |  | var | ) | FOR_ALL_CLIENT_SOCKETS_FROM(var, 0)

Iterate over all the sockets.

Parameters:

  | var | The variable to iterate with.

Definition at line 141 of file network_server.h.

Referenced by DistributeCommandPacket(), ServerNetworkGameSocketHandler::GetByClientID(), NetworkClose(), NetworkCountActiveClients(), NetworkDisconnect(), NetworkDistributeCommands(), NetworkHasJoiningClient(), NetworkServer_Tick(), NetworkServerKickOrBanIP(), NetworkServerSendChat(), NetworkServerSendConfigUpdate(), NetworkServerShowStatusToConsole(), NetworkServerUpdateCompanyPassworded(), NetworkUpdateClientInfo(), ServerNetworkGameSocketHandler::Send(), ServerNetworkGameSocketHandler::SendCompanyInfo(), ServerNetworkGameSocketHandler::SendError(), ServerNetworkGameSocketHandler::SendMap(), ServerNetworkGameSocketHandler::SendWait(), and ServerNetworkGameSocketHandler::SendWelcome().

#define FOR_ALL_CLIENT_SOCKETS_FROM | ( |  | var,
|  |  | start |
| ) |  |  | FOR_ALL_ITEMS_FROM(NetworkClientSocket, clientsocket_index, var, start)

Iterate over all the sockets from a given starting point.

Parameters:

  | var | The variable to iterate with.
  | start | The start of the iteration.

Definition at line 135 of file network_server.h.

## Typedef Documentation

typedef ServerNetworkGameSocketHandler NetworkClientSocket

Make the code look slightliy nicer/simpler.

Definition at line 21 of file network_server.h.

typedef Pool<NetworkClientSocket, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT> NetworkClientSocketPool

Pool with all client sockets.

Definition at line 25 of file network_server.h.

## Function Documentation

void NetworkServer_Tick | ( | bool | send_frame | ) |

This is called every tick if this is a _network_server.

Parameters:

  | send_frame | Whether to send the frame to the clients.

Definition at line 1762 of file network_server.cpp.

References _frame_counter, _last_sync_frame, _realtime_tick, _settings_client, NetworkSettings::bytes_per_frame, NetworkSettings::bytes_per_frame_burst, CC_ERROR, CC_WARNING, DAY_TICKS, FOR_ALL_CLIENT_SOCKETS, IConsolePrintF(), NetworkSettings::max_download_time, NetworkSettings::max_init_time, NetworkSettings::max_join_time, NetworkSettings::max_lag_time, NetworkSettings::max_password_time, MILLISECONDS_PER_TICK, min(), ClientSettings::network, NetworkHandleCommandQueue(), NetworkUDPAdvertise(), and NetworkSettings::sync_freq.

void NetworkServerSetCompanyPassword | ( | CompanyID | company_id,
|  | const char * | password,
|  | bool | already_hashed |
| ) |  |  |

Set/Reset a company password on the server end.

Parameters:

  | company_id | ID of the company the password should be changed for.
  | password | The new password.
  | already_hashed | Is the given password already hashed?

Definition at line 1733 of file network_server.cpp.

References _network_company_states, _settings_client, _settings_game, GameSettings::game_creation, GenerateCompanyPasswordHash(), GameCreationSettings::generation_seed, Company::IsValidHumanID(), lastof, ClientSettings::network, NetworkSettings::network_id, NetworkServerUpdateCompanyPassworded(), strecpy(), and StrEmpty().

Referenced by NetworkChangeCompanyPassword().

## Variable Documentation

NetworkClientSocketPool _networkclientsocket_pool

The pool with clients.