OpenTTD Source 20260421-master-gc2fbc6fdeb
TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet > Class Template Reference

Template for TCP listeners. More...

#include <tcp_listen.h>

Static Public Member Functions

static bool ValidateClient (SOCKET s, NetworkAddress &address)
 Check whether this client is allowed to connect, by both the banlist and maximum client count.
static void AcceptClient (SOCKET ls)
 Accepts clients from the sockets.
static bool Receive ()
 Handle the receiving of packets.
static bool Listen (uint16_t port)
 Listen on a particular port.
static void CloseListeners ()
 Close the sockets we're listening on.

Static Private Attributes

static SocketList sockets
 List of sockets we listen on.

Detailed Description

template<class Tsocket, typename EnumPacketType, EnumPacketType Tfull_packet, EnumPacketType Tban_packet>
class TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >

Template for TCP listeners.

Parameters
TsocketThe class we create sockets for.
EnumPacketTypeThe enumeration type of the packet type.
Tfull_packetThe packet type to return when we don't allow more sockets.
Tban_packetThe packet type to return when the client is banned.

Definition at line 29 of file tcp_listen.h.

Member Function Documentation

◆ AcceptClient()

template<class Tsocket, typename EnumPacketType, EnumPacketType Tfull_packet, EnumPacketType Tban_packet>
void TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::AcceptClient ( SOCKET ls)
inlinestatic

Accepts clients from the sockets.

Parameters
lsSocket to accept clients from.

Definition at line 80 of file tcp_listen.h.

References _frame_counter, Debug, NetworkAddress::GetHostname(), SetNoDelay(), and SetNonBlocking().

Referenced by Receive().

◆ CloseListeners()

template<class Tsocket, typename EnumPacketType, EnumPacketType Tfull_packet, EnumPacketType Tban_packet>
void TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::CloseListeners ( )
inlinestatic

Close the sockets we're listening on.

Definition at line 170 of file tcp_listen.h.

References Debug, and sockets.

◆ Listen()

template<class Tsocket, typename EnumPacketType, EnumPacketType Tfull_packet, EnumPacketType Tban_packet>
bool TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::Listen ( uint16_t port)
inlinestatic

Listen on a particular port.

Parameters
portThe port to listen on.
Returns
true if listening succeeded.

Definition at line 149 of file tcp_listen.h.

References Debug, GetBindAddresses(), ShowNetworkError(), and sockets.

◆ Receive()

template<class Tsocket, typename EnumPacketType, EnumPacketType Tfull_packet, EnumPacketType Tban_packet>
bool TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::Receive ( )
inlinestatic

Handle the receiving of packets.

Returns
true if everything went okay.

Definition at line 107 of file tcp_listen.h.

References _networking, AcceptClient(), and sockets.

◆ ValidateClient()

template<class Tsocket, typename EnumPacketType, EnumPacketType Tfull_packet, EnumPacketType Tban_packet>
bool TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::ValidateClient ( SOCKET s,
NetworkAddress & address )
inlinestatic

Check whether this client is allowed to connect, by both the banlist and maximum client count.

Parameters
sThe socket/network connection to the client.
addressThe address of the client.
Returns
true iff the client is allowed in.

Definition at line 40 of file tcp_listen.h.

References _network_ban_list, Debug, NetworkError::GetLast(), NetworkAddress::IsInNetmask(), Packet::PrepareToSend(), and Packet::TransferOut().

Field Documentation

◆ sockets

template<class Tsocket, typename EnumPacketType, EnumPacketType Tfull_packet, EnumPacketType Tban_packet>
SocketList TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::sockets
staticprivate

List of sockets we listen on.

Definition at line 31 of file tcp_listen.h.

Referenced by CloseListeners(), Listen(), and Receive().


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