SocketHandler for all network sockets in OpenTTD. More...
#include <core.h>
Public Member Functions | |
NetworkSocketHandler () | |
Create a new unbound socket. | |
virtual | ~NetworkSocketHandler () |
Close the socket when distructing the socket handler. | |
virtual void | Close () |
Really close the socket. | |
virtual NetworkRecvStatus | CloseConnection (bool error=true) |
Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just means the packet has to be dropped. | |
bool | HasClientQuit () const |
Whether the current client connected to the socket has quit. | |
void | Reopen () |
Reopen the socket so we can send/receive stuff again. | |
void | Send_GRFIdentifier (Packet *p, const GRFIdentifier *grf) |
Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet. | |
void | Recv_GRFIdentifier (Packet *p, GRFIdentifier *grf) |
Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet. | |
void | Send_CompanyInformation (Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats) |
Private Attributes | |
bool | has_quit |
Whether the current client has quit/send a bad packet. |
SocketHandler for all network sockets in OpenTTD.
Definition at line 44 of file core.h.
virtual NetworkRecvStatus NetworkSocketHandler::CloseConnection | ( | bool | error = true |
) | [inline, virtual] |
Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just means the packet has to be dropped.
error | Whether we quit under an error condition or not. |
Reimplemented in NetworkTCPSocketHandler, NetworkClientSocket, NetworkHTTPSocketHandler, and NetworkUDPSocketHandler.
Definition at line 62 of file core.h.
References has_quit, and NETWORK_RECV_STATUS_OKAY.
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.
Definition at line 70 of file core.h.
References has_quit.
Referenced by Packet::CanReadFromPacket(), DEF_SERVER_RECEIVE_COMMAND(), NetworkContentSocketHandler::HandlePacket(), NetworkUDPSocketHandler::HandleUDPPacket(), and Packet::Recv_string().
void NetworkSocketHandler::Recv_GRFIdentifier | ( | Packet * | p, | |
GRFIdentifier * | grf | |||
) |
Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet.
p | the packet to read the data from | |
grf | the GRFIdentifier to deserialize |
Definition at line 120 of file core.cpp.
References GRFIdentifier::grfid, and GRFIdentifier::md5sum.
Referenced by NetworkUDPSocketHandler::Recv_NetworkGameInfo().
void NetworkSocketHandler::Send_GRFIdentifier | ( | Packet * | p, | |
const GRFIdentifier * | grf | |||
) |
Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet.
p | the packet to write the data to | |
grf | the GRFIdentifier to serialize |
Definition at line 106 of file core.cpp.
References GRFIdentifier::grfid, and GRFIdentifier::md5sum.
Referenced by NetworkUDPSocketHandler::Send_NetworkGameInfo().