OpenTTD Source: NetworkSocketHandler Class Reference

OpenTTD Source 12.0-beta1

Public Member Functions | Private Attributes
NetworkSocketHandler Class Reference

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

`#include <core.h>`

Inheritance diagram for NetworkSocketHandler:

## Public Member Functions
| NetworkSocketHandler ()
| Create a new unbound socket.
virtual | ~NetworkSocketHandler ()
| 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.

## Private Attributes
bool | has_quit
| Whether the current client has quit/send a bad packet.

## Detailed Description

SocketHandler for all network sockets in OpenTTD.

Definition at line 42 of file core.h.

## Member Function Documentation

## ◆ HasClientQuit()

bool NetworkSocketHandler::HasClientQuit | ( |  | ) | const
| inline

Whether the current client connected to the socket has quit.

In the case of UDP, for example, once a client quits (send bad data), the socket in not closed; only the packet is dropped.

Returns
  true when the current client has quit, false otherwise

Definition at line 68 of file core.h.

References has_quit.

Referenced by Packet::CanReadFromPacket(), ServerNetworkGameSocketHandler::CloseConnection(), ClientNetworkGameSocketHandler::CloseConnection(), NetworkContentSocketHandler::HandlePacket(), NetworkAdminSocketHandler::HandlePacket(), NetworkGameSocketHandler::HandlePacket(), NetworkUDPSocketHandler::HandleUDPPacket(), ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(), ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(), ServerNetworkGameSocketHandler::Receive_CLIENT_GETMAP(), ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK(), ServerNetworkGameSocketHandler::Receive_CLIENT_QUIT(), and ClientNetworkGameSocketHandler::Receive_SERVER_NEED_COMPANY_PASSWORD().

## ◆ 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 60 of file core.h.

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

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

- src/network/core/core.h