# NetworkContentSocketHandler Class Reference

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

`#include <tcp_content.h>`

Inheritance diagram for NetworkContentSocketHandler:

## Public Member Functions
| NetworkContentSocketHandler (SOCKET s=INVALID_SOCKET, const NetworkAddress &address=NetworkAddress())
| Create a new cs socket handler for a given cs.
virtual | ~NetworkContentSocketHandler ()
| On destructing of this class, the socket needs to be closed.
void | Recv_Packets ()
| Do the actual receiving of packets.
## Protected Member Functions
virtual void | Close ()
| Really close the socket.
| DECLARE_CONTENT_RECEIVE_COMMAND (PACKET_CONTENT_CLIENT_INFO_LIST)
| Client requesting a list of content info: byte type uint32 openttd version.
| DECLARE_CONTENT_RECEIVE_COMMAND (PACKET_CONTENT_CLIENT_INFO_ID)
| Client requesting a list of content info: uint16 count of ids uint32 id (count times).
| DECLARE_CONTENT_RECEIVE_COMMAND (PACKET_CONTENT_CLIENT_INFO_EXTID)
| Client requesting a list of content info based on an external 'unique' id; GRF ID for NewGRFS, shortname and for base graphics and AIs.
| DECLARE_CONTENT_RECEIVE_COMMAND (PACKET_CONTENT_CLIENT_INFO_EXTID_MD5)
| Client requesting a list of content info based on an external 'unique' id; GRF ID + MD5 checksum for NewGRFS, shortname and xor-ed MD5 checsums for base graphics and AIs.
| DECLARE_CONTENT_RECEIVE_COMMAND (PACKET_CONTENT_SERVER_INFO)
| Server sending list of content info: byte type (invalid ID == does not exist) uint32 id uint32 file_size string name (max 32 characters) string version (max 16 characters) uint32 unique id uint8 md5sum (16 bytes) uint8 dependency count uint32 unique id of dependency (dependency count times) uint8 tag count string tag (max 32 characters for tag count times).
| DECLARE_CONTENT_RECEIVE_COMMAND (PACKET_CONTENT_CLIENT_CONTENT)
| Client requesting the actual content: uint16 count of unique ids uint32 unique id (count times).
| DECLARE_CONTENT_RECEIVE_COMMAND (PACKET_CONTENT_SERVER_CONTENT)
| Server sending list of content info: uint32 unique id uint32 file size (0 == does not exist) string file name (max 48 characters) After this initial packet, packets with the actual data are send using the same packet type.
bool | HandlePacket (Packet *p)
| Handle the given packet, i.e.
## Protected Attributes
NetworkAddress | client_addr
| The address we're connected to.

## Detailed Description

Base socket handler for all Content TCP sockets.

Definition at line 113 of file tcp_content.h.

## Constructor & Destructor Documentation

NetworkContentSocketHandler::NetworkContentSocketHandler | ( | SOCKET | s = `INVALID_SOCKET`,
|  | const NetworkAddress & | address = `NetworkAddress()` |
| ) |  |  | `[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 203 of file tcp_content.h.

## Member Function Documentation

NetworkContentSocketHandler::DECLARE_CONTENT_RECEIVE_COMMAND | ( | PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 |  | ) | `[protected]`

Client requesting a list of content info based on an external 'unique' id; GRF ID + MD5 checksum for NewGRFS, shortname and xor-ed MD5 checsums for base graphics and AIs.

Scenarios and AI libraries are not supported uint8 count of requests for each request: uint8 type unique id (uint32) md5 (16 bytes)

NetworkContentSocketHandler::DECLARE_CONTENT_RECEIVE_COMMAND | ( | PACKET_CONTENT_CLIENT_INFO_EXTID |  | ) | `[protected]`

Client requesting a list of content info based on an external 'unique' id; GRF ID for NewGRFS, shortname and for base graphics and AIs.

Scenarios and AI libraries are not supported uint8 count of requests for each request: uint8 type unique id (uint32)

bool NetworkContentSocketHandler::HandlePacket | ( | Packet * | p | ) | `[protected]`

Handle the given packet, i.e.

Handle an incoming packets by sending it to the correct function.

pass it to the right parser receive command.

Parameters:

  | p | the packet to handle

Returns:
  true if we should immediatelly handle further packets, false otherwise

Parameters:

  | p | the received packet

Definition at line 94 of file tcp_content.cpp.

References client_addr, CONTENT_COMMAND, NetworkAddress::GetAddressAsString(), NetworkSocketHandler::HasClientQuit(), PACKET_CONTENT_CLIENT_CONTENT, PACKET_CONTENT_CLIENT_INFO_EXTID, PACKET_CONTENT_CLIENT_INFO_EXTID_MD5, PACKET_CONTENT_CLIENT_INFO_ID, PACKET_CONTENT_CLIENT_INFO_LIST, PACKET_CONTENT_END, PACKET_CONTENT_SERVER_CONTENT, and PACKET_CONTENT_SERVER_INFO.

Referenced by Recv_Packets().

void NetworkContentSocketHandler::Recv_Packets | ( |  | ) |

Do the actual receiving of packets.

Receive a packet at UDP level.

Definition at line 120 of file tcp_content.cpp.

References HandlePacket(), and NetworkTCPSocketHandler::Recv_Packet().

Referenced by ClientNetworkContentSocketHandler::SendReceive().

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

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