OpenTTD Source: TCPListenHandler< Tsocket, Tfull_packet, Tban_packet > Class Template Reference

OpenTTD Source 15.3

Static Public Member Functions | Static Private Attributes
TCPListenHandler< Tsocket, 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)
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, PacketType Tfull_packet, PacketType Tban_packet>
class TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >

Template for TCP listeners.

Parameters

  Tsocket | The class we create sockets for.
  Tfull_packet | The packet type to return when we don't allow more sockets.
  Tban_packet | The packet type to return when the client is banned.

Definition at line 30 of file tcp_listen.h.

## Member Function Documentation

## ◆ AcceptClient()

template<class Tsocket , PacketType Tfull_packet, PacketType Tban_packet>

static void TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::AcceptClient | ( | SOCKET | ls | ) |
| inlinestatic

Accepts clients from the sockets.

Parameters

  ls | Socket to accept clients from.

Definition at line 75 of file tcp_listen.h.

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

Referenced by TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::Receive().

## ◆ CloseListeners()

template<class Tsocket , PacketType Tfull_packet, PacketType Tban_packet>

static void TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::CloseListeners | ( |  | ) |
| inlinestatic

Close the sockets we're listening on.

Definition at line 165 of file tcp_listen.h.

References Debug, and TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::sockets.

## ◆ Listen()

template<class Tsocket , PacketType Tfull_packet, PacketType Tban_packet>

static bool TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::Listen | ( | uint16_t | port | ) |
| inlinestatic

Listen on a particular port.

Parameters

  port | The port to listen on.

Returns
  true if listening succeeded.

Definition at line 144 of file tcp_listen.h.

References Debug, GetBindAddresses(), and TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::sockets.

## ◆ Receive()

template<class Tsocket , PacketType Tfull_packet, PacketType Tban_packet>

static bool TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::Receive | ( |  | ) |
| inlinestatic

Handle the receiving of packets.

Returns
  true if everything went okay.

Definition at line 102 of file tcp_listen.h.

References _networking, TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::AcceptClient(), and TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::sockets.

## ◆ ValidateClient()

template<class Tsocket , PacketType Tfull_packet, PacketType Tban_packet>

static bool TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::ValidateClient | ( | SOCKET | s,
|  | NetworkAddress & | address
| ) |  |
| inlinestatic

Definition at line 35 of file tcp_listen.h.

## Field Documentation

## ◆ sockets

template<class Tsocket , PacketType Tfull_packet, PacketType Tban_packet>

SocketList TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::sockets
| staticprivate

List of sockets we listen on.

Definition at line 32 of file tcp_listen.h.

Referenced by TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::CloseListeners(), TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::Listen(), and TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::Receive().

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

- src/network/core/tcp_listen.h