OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
12 #ifndef NETWORK_CORE_UDP_H
13 #define NETWORK_CORE_UDP_H
Base socket handler for all UDP sockets.
void SendPacket(Packet &p, NetworkAddress &recv, bool all=false, bool broadcast=false)
Send a packet over UDP.
SocketHandler for all network sockets in OpenTTD.
virtual void Receive_CLIENT_FIND_SERVER(Packet &p, NetworkAddress &client_addr)
Queries to the server for information about the game.
void CloseSocket()
Close the actual UDP socket.
NetworkUDPSocketHandler(NetworkAddressList *bind=nullptr)
Create an UDP socket but don't listen yet.
std::map< SOCKET, NetworkAddress > SocketList
Type for a mapping between address and socket.
virtual void Receive_SERVER_RESPONSE(Packet &p, NetworkAddress &client_addr)
Response to a query letting the client know we are here.
@ PACKET_UDP_SERVER_RESPONSE
Reply of the game server with game information.
virtual ~NetworkUDPSocketHandler()
On destructing of this class, the socket needs to be closed.
std::vector< NetworkAddress > NetworkAddressList
Type for a list of addresses.
SocketList sockets
The opened sockets.
NetworkAddressList bind
The address to bind to.
void HandleUDPPacket(Packet &p, NetworkAddress &client_addr)
Handle an incoming packets by sending it to the correct function.
Internal entity of a packet.
@ PACKET_UDP_CLIENT_FIND_SERVER
Queries a game server for game information.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
PacketUDPType
Enum with all types of UDP packets.
bool Listen()
Start listening on the given host and port.
@ PACKET_UDP_END
Must ALWAYS be on the end of this list!! (period)
void ReceivePackets()
Receive a packet at UDP level.
void ReceiveInvalidPacket(PacketUDPType, NetworkAddress &client_addr)
Helper for logging receiving invalid packets.