OpenTTD Source: NetworkStunSocketHandler Class Reference

OpenTTD Source 14.0-beta3

Public Member Functions | Protected Member Functions
NetworkStunSocketHandler Class Reference

Base socket handler for all STUN TCP sockets. More...

`#include <tcp_stun.h>`

Inheritance diagram for NetworkStunSocketHandler:

## Public Member Functions
| NetworkStunSocketHandler (SOCKET s=INVALID_SOCKET)
| Create a new cs socket handler for a given cs. More...
Public Member Functions inherited from NetworkTCPSocketHandler
bool | IsConnected () const
| Whether this socket is currently bound to a socket. More...
virtual NetworkRecvStatus | CloseConnection (bool error=true)
| This will put this socket handler in a close state. More...
void | CloseSocket ()
| Close the actual socket of the connection. More...
virtual void | SendPacket (std::unique_ptr< Packet > &&packet)
| This function puts the packet in the send-queue and it is send as soon as possible. More...
SendPacketsState | SendPackets (bool closing_down=false)
| Sends all the buffered packets out for this client. More...
virtual std::unique_ptr< Packet > | ReceivePacket ()
| Receives a packet for the given client. More...
bool | CanSendReceive ()
| Check whether this socket can send or receive something. More...
bool | HasSendQueue ()
| Whether there is something pending in the send queue. More...
| NetworkTCPSocketHandler (SOCKET s=INVALID_SOCKET)
| Construct a socket handler for a TCP connection. More...
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
bool | ReceiveInvalidPacket (PacketStunType type)
| Helper for logging receiving invalid packets. More...
virtual bool | Receive_SERCLI_STUN (Packet &p)
| Send a STUN request to the STUN server letting the Game Coordinator know what our actually public IP:port is. More...

## Additional Inherited Members
Data Fields inherited from NetworkTCPSocketHandler
SOCKET | sock
| The socket currently connected to.
bool | writable
| Can we write to this socket?

## Detailed Description

Base socket handler for all STUN TCP sockets.

Definition at line 26 of file tcp_stun.h.

## Constructor & Destructor Documentation

## ◆ NetworkStunSocketHandler()

NetworkStunSocketHandler::NetworkStunSocketHandler | ( | SOCKET | s = `INVALID_SOCKET` | ) |
| inline

Create a new cs socket handler for a given cs.

Parameters

  s | the socket we are connected with.
  address | IP etc. of the client.

Definition at line 50 of file tcp_stun.h.

## Member Function Documentation

## ◆ Receive_SERCLI_STUN()

bool NetworkStunSocketHandler::Receive_SERCLI_STUN | ( | Packet & | p | ) |
| protectedvirtual

Send a STUN request to the STUN server letting the Game Coordinator know what our actually public IP:port is.

uint8_t Game Coordinator protocol version. string Token to track the current STUN request. uint8_t Which interface number this is (for example, IPv4 or IPv6). The Game Coordinator relays this number back in later packets.

Parameters

  p | The packet that was just received.

Returns
  True upon success, otherwise false.

Definition at line 29 of file tcp_stun.cpp.

References PACKET_STUN_SERCLI_STUN, and ReceiveInvalidPacket().

## ◆ ReceiveInvalidPacket()

bool NetworkStunSocketHandler::ReceiveInvalidPacket | ( | PacketStunType | type | ) |
| protected

Helper for logging receiving invalid packets.

Parameters

  type | The received packet type.

Returns
  Always false, as it's an error.

Definition at line 23 of file tcp_stun.cpp.

References Debug.

Referenced by Receive_SERCLI_STUN().

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

- src/network/core/tcp_stun.h
- src/network/core/tcp_stun.cpp