OpenTTD Source: src/network/network_udp.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions | Variables
network_udp.cpp File Reference

This file handles the UDP related communication. More...

`#include "../stdafx.h"`
`#include "../debug.h"`
`#include "network_internal.h"`
`#include "network_udp.h"`
`#include "core/udp.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | UDPSocket
| Some information about a socket, which exists before the actual socket has been created to provide locking and the likes. More...
class | ServerNetworkUDPSocketHandler
| Helper class for handling all server side communication. More...
class | ClientNetworkUDPSocketHandler
| Helper class for handling all client side communication. More...

## Functions
static void | NetworkUDPBroadCast (NetworkUDPSocketHandler &socket)
| Broadcast to all ips.
void | NetworkUDPSearchGame ()
| Find all servers.
void | NetworkUDPInitialize ()
| Initialize the whole UDP bit.
void | NetworkUDPServerListen ()
| Start the listening of the UDP server component.
void | NetworkUDPClose ()
| Close all UDP related stuff.
void | NetworkBackgroundUDPLoop ()
| Receive the UDP packets.

## Variables
static bool | _network_udp_server
| Is the UDP server started?
static uint16_t | _network_udp_broadcast
| Timeout for the UDP broadcasts.
static UDPSocket | _udp_client ("Client")
| udp client socket
static UDPSocket | _udp_server ("Server")
| udp server socket

## Detailed Description

This file handles the UDP related communication.

This is the GameServer <-> GameClient communication before the game is being joined.

Definition in file network_udp.cpp.

## Function Documentation

## ◆ NetworkBackgroundUDPLoop()

void NetworkBackgroundUDPLoop | ( |  | ) |

Receive the UDP packets.

Definition at line 150 of file network_udp.cpp.

References _network_udp_broadcast, _network_udp_server, _udp_client, and _udp_server.

Referenced by NetworkBackgroundLoop().

## ◆ NetworkUDPBroadCast()

static void NetworkUDPBroadCast | ( | NetworkUDPSocketHandler & | socket | ) |
| static

Broadcast to all ips.

Definition at line 91 of file network_udp.cpp.

References _broadcast_list, Debug, PACKET_UDP_CLIENT_FIND_SERVER, and NetworkUDPSocketHandler::SendPacket().

Referenced by NetworkUDPSearchGame().

## ◆ NetworkUDPClose()

void NetworkUDPClose | ( |  | ) |

Close all UDP related stuff.

Definition at line 139 of file network_udp.cpp.

References _network_udp_broadcast, _network_udp_server, _udp_client, _udp_server, and Debug.

Referenced by NetworkShutDown(), and NetworkUDPInitialize().

## ◆ NetworkUDPInitialize()

void NetworkUDPInitialize | ( |  | ) |

Initialize the whole UDP bit.

Definition at line 114 of file network_udp.cpp.

References _network_udp_broadcast, _network_udp_server, _settings_client, _udp_client, _udp_server, Debug, GetBindAddresses(), ClientSettings::network, NetworkUDPClose(), NetworkSettings::server_port, and UDPSocket::socket.

Referenced by NetworkDisconnect(), and NetworkStartUp().

## ◆ NetworkUDPSearchGame()

void NetworkUDPSearchGame | ( |  | ) |

Find all servers.

Definition at line 102 of file network_udp.cpp.

References _network_udp_broadcast, _udp_client, Debug, NetworkUDPBroadCast(), and UDPSocket::socket.

Referenced by NetworkGameWindow::OnClick().

## ◆ NetworkUDPServerListen()

void NetworkUDPServerListen | ( |  | ) |

Start the listening of the UDP server component.

Definition at line 133 of file network_udp.cpp.

References _network_udp_server, _udp_server, and UDPSocket::socket.

## Variable Documentation

## ◆ _network_udp_broadcast

uint16_t _network_udp_broadcast
| static

Timeout for the UDP broadcasts.

Definition at line 26 of file network_udp.cpp.

Referenced by NetworkBackgroundUDPLoop(), NetworkUDPClose(), NetworkUDPInitialize(), and NetworkUDPSearchGame().

## ◆ _network_udp_server

bool _network_udp_server
| static

Is the UDP server started?

Definition at line 25 of file network_udp.cpp.

Referenced by NetworkBackgroundUDPLoop(), NetworkUDPClose(), NetworkUDPInitialize(), and NetworkUDPServerListen().