OpenTTD Source
20241111-master-gce64d5f5d9
|
Base socket handler for all STUN TCP sockets. More...
#include <tcp_stun.h>
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? | |
Protected Attributes inherited from NetworkSocketHandler | |
std::unique_ptr< class NetworkEncryptionHandler > | receive_encryption_handler |
The handler for decrypting received packets. | |
std::unique_ptr< class NetworkEncryptionHandler > | send_encryption_handler |
The handler for encrypting sent packets. | |
Base socket handler for all STUN TCP sockets.
Definition at line 26 of file tcp_stun.h.
|
inline |
Create a new cs socket handler for a given cs.
s | the socket we are connected with. |
address | IP etc. of the client. |
Definition at line 50 of file tcp_stun.h.
|
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.
p | The packet that was just received. |
Definition at line 29 of file tcp_stun.cpp.
References PACKET_STUN_SERCLI_STUN, and ReceiveInvalidPacket().
|
protected |
Helper for logging receiving invalid packets.
type | The received packet type. |
Definition at line 23 of file tcp_stun.cpp.
References Debug.
Referenced by Receive_SERCLI_STUN().