OpenTTD Source
12.0-beta2
|
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.
SocketHandler for all network sockets in OpenTTD.
@ PACKET_UDP_CLIENT_FIND_SERVER
Queries a game server for game information.
void CloseSocket()
Close the actual UDP socket.
NetworkUDPSocketHandler(NetworkAddressList *bind=nullptr)
Create an UDP socket but don't listen yet.
virtual void Receive_CLIENT_FIND_SERVER(Packet *p, NetworkAddress *client_addr)
Queries to the server for information about the game.
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.
@ PACKET_UDP_END
Must ALWAYS be on the end of this list!! (period)
NetworkAddressList bind
The address to bind to.
Internal entity of a packet.
void ReceiveInvalidPacket(PacketUDPType, NetworkAddress *client_addr)
Helper for logging receiving invalid packets.
@ PACKET_UDP_SERVER_RESPONSE
Reply of the game server with game information.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
void HandleUDPPacket(Packet *p, NetworkAddress *client_addr)
Handle an incoming packets by sending it to the correct function.
bool Listen()
Start listening on the given host and port.
void ReceivePackets()
Receive a packet at UDP level.
virtual void Receive_SERVER_RESPONSE(Packet *p, NetworkAddress *client_addr)
Response to a query letting the client know we are here.
PacketUDPType
Enum with all types of UDP packets.
void SendPacket(Packet *p, NetworkAddress *recv, bool all=false, bool broadcast=false)
Send a packet over UDP.