OpenTTD Source 20251216-master-g483f1f0afa
NetworkSocketHandler Class Reference

SocketHandler for all network sockets in OpenTTD. More...

#include <core.h>

Inheritance diagram for NetworkSocketHandler:
MockNetworkSocketHandler NetworkTCPSocketHandler NetworkUDPSocketHandler NetworkAdminSocketHandler NetworkContentSocketHandler NetworkCoordinatorSocketHandler NetworkGameSocketHandler NetworkStunSocketHandler NetworkTurnSocketHandler ClientNetworkUDPSocketHandler ServerNetworkUDPSocketHandler

Public Member Functions

 NetworkSocketHandler ()=default
 Create a new unbound socket.
 
virtual ~NetworkSocketHandler ()=default
 Close the socket when destructing the socket handler.
 
void MarkClosed ()
 Mark the connection as closed.
 
bool HasClientQuit () const
 Whether the current client connected to the socket has quit.
 
void Reopen ()
 Reopen the socket so we can send/receive stuff again.
 

Protected Attributes

std::unique_ptr< class NetworkEncryptionHandlerreceive_encryption_handler = nullptr
 The handler for decrypting received packets.
 
std::unique_ptr< class NetworkEncryptionHandlersend_encryption_handler = nullptr
 The handler for encrypting sent packets.
 

Private Attributes

bool has_quit = false
 Whether the current client has quit/send a bad packet.
 

Friends

struct Packet
 

Detailed Description

SocketHandler for all network sockets in OpenTTD.

Definition at line 41 of file core.h.

Member Function Documentation

◆ HasClientQuit()

◆ MarkClosed()

void NetworkSocketHandler::MarkClosed ( )
inline

Mark the connection as closed.

This doesn't mean the actual connection is closed, but just that we act like it is. This is useful for UDP, which doesn't normally close a socket, but its handler might need to pretend it does.

Definition at line 64 of file core.h.

Referenced by ClientNetworkGameSocketHandler::ClientError(), and NetworkTCPSocketHandler::CloseConnection().

◆ Reopen()

void NetworkSocketHandler::Reopen ( )
inline

Reopen the socket so we can send/receive stuff again.

Definition at line 77 of file core.h.

Referenced by NetworkUDPSocketHandler::HandleUDPPacket(), and NetworkContentConnecter::OnConnect().

Friends And Related Symbol Documentation

◆ Packet

friend struct Packet
friend

Definition at line 46 of file core.h.

Field Documentation

◆ has_quit

bool NetworkSocketHandler::has_quit = false
private

Whether the current client has quit/send a bad packet.

Definition at line 43 of file core.h.

Referenced by HasClientQuit().

◆ receive_encryption_handler

std::unique_ptr<class NetworkEncryptionHandler> NetworkSocketHandler::receive_encryption_handler = nullptr
protected

◆ send_encryption_handler

std::unique_ptr<class NetworkEncryptionHandler> NetworkSocketHandler::send_encryption_handler = nullptr
protected

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