OpenTTD Source  20240919-master-gdf0233f4c2
ServerNetworkUDPSocketHandler Class Reference

‍*** Communication with clients (we are server) ***‍/ More...

Inheritance diagram for ServerNetworkUDPSocketHandler:
NetworkUDPSocketHandler NetworkSocketHandler

Public Member Functions

 ServerNetworkUDPSocketHandler (NetworkAddressList *addresses)
 Create the socket. More...
 
- Public Member Functions inherited from NetworkUDPSocketHandler
 NetworkUDPSocketHandler (NetworkAddressList *bind=nullptr)
 Create an UDP socket but don't listen yet. More...
 
virtual ~NetworkUDPSocketHandler ()
 On destructing of this class, the socket needs to be closed.
 
bool Listen ()
 Start listening on the given host and port. More...
 
void CloseSocket ()
 Close the actual UDP socket.
 
void SendPacket (Packet &p, NetworkAddress &recv, bool all=false, bool broadcast=false)
 Send a packet over UDP. More...
 
void ReceivePackets ()
 Receive a packet at UDP level.
 
- Public Member Functions inherited from NetworkSocketHandler
 NetworkSocketHandler ()
 Create a new unbound socket.
 
virtual ~NetworkSocketHandler ()=default
 Close the socket when destructing the socket handler.
 
void MarkClosed ()
 Mark the connection as closed. More...
 
bool HasClientQuit () const
 Whether the current client connected to the socket has quit. More...
 
void Reopen ()
 Reopen the socket so we can send/receive stuff again.
 

Protected Member Functions

void Receive_CLIENT_FIND_SERVER (Packet &p, NetworkAddress &client_addr) override
 Queries to the server for information about the game. More...
 
- Protected Member Functions inherited from NetworkUDPSocketHandler
void ReceiveInvalidPacket (PacketUDPType, NetworkAddress &client_addr)
 Helper for logging receiving invalid packets. More...
 
virtual void Receive_SERVER_RESPONSE (Packet &p, NetworkAddress &client_addr)
 Response to a query letting the client know we are here. More...
 
void HandleUDPPacket (Packet &p, NetworkAddress &client_addr)
 Handle an incoming packets by sending it to the correct function. More...
 

Additional Inherited Members

- Protected Attributes inherited from NetworkUDPSocketHandler
NetworkAddressList bind
 The address to bind to.
 
SocketList sockets
 The opened sockets.
 
- Protected Attributes inherited from NetworkSocketHandler
std::unique_ptr< class NetworkEncryptionHandlerreceive_encryption_handler
 The handler for decrypting received packets.
 
std::unique_ptr< class NetworkEncryptionHandlersend_encryption_handler
 The handler for encrypting sent packets.
 

Detailed Description

‍*** Communication with clients (we are server) ***‍/

Helper class for handling all server side communication.

Definition at line 64 of file network_udp.cpp.

Constructor & Destructor Documentation

◆ ServerNetworkUDPSocketHandler()

ServerNetworkUDPSocketHandler::ServerNetworkUDPSocketHandler ( NetworkAddressList addresses)
inline

Create the socket.

Parameters
addressesThe addresses to bind on.

Definition at line 72 of file network_udp.cpp.

Member Function Documentation

◆ Receive_CLIENT_FIND_SERVER()

void ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER ( Packet p,
NetworkAddress client_addr 
)
overrideprotectedvirtual

Queries to the server for information about the game.

Parameters
pThe received packet.
client_addrThe origin of the packet.

Reimplemented from NetworkUDPSocketHandler.

Definition at line 76 of file network_udp.cpp.

References Debug, NetworkAddress::GetHostname(), PACKET_UDP_SERVER_RESPONSE, and NetworkUDPSocketHandler::SendPacket().


The documentation for this class was generated from the following file: