| OpenTTD
    | 
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 destructing 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 | SendGRFIdentifier (Packet *p, const GRFIdentifier *grf) | 
| Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet. | |
| void | ReceiveGRFIdentifier (Packet *p, GRFIdentifier *grf) | 
| Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet. | |
| void | SendCompanyInformation (Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats, uint max_len=NETWORK_COMPANY_NAME_LENGTH) | 
| Package some generic company information into a packet. | |
| Private Attributes | |
| bool | has_quit | 
| Whether the current client has quit/send a bad packet. | |
| 
 | inlinevirtual | 
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 NetworkGameSocketHandler, NetworkAdminSocketHandler, NetworkHTTPSocketHandler, NetworkUDPSocketHandler, and NetworkTCPSocketHandler.
Definition at line 63 of file core.h.
References has_quit, and NETWORK_RECV_STATUS_OKAY.
| 
 | 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 71 of file core.h.
References has_quit.
Referenced by Packet::CanReadFromPacket(), ServerNetworkGameSocketHandler::CloseConnection(), NetworkContentSocketHandler::HandlePacket(), NetworkAdminSocketHandler::HandlePacket(), NetworkGameSocketHandler::HandlePacket(), NetworkUDPSocketHandler::HandleUDPPacket(), ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(), ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(), ServerNetworkGameSocketHandler::Receive_CLIENT_GETMAP(), ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(), ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK(), ServerNetworkGameSocketHandler::Receive_CLIENT_QUIT(), ServerNetworkGameSocketHandler::Receive_CLIENT_SET_NAME(), ClientNetworkUDPSocketHandler::Receive_MASTER_RESPONSE_LIST(), ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(), ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_INFO(), ClientNetworkGameSocketHandler::Receive_SERVER_NEED_COMPANY_PASSWORD(), and Packet::Recv_string().
| void NetworkSocketHandler::ReceiveGRFIdentifier | ( | 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 122 of file core.cpp.
References GRFIdentifier::grfid, GRFIdentifier::md5sum, Packet::Recv_uint32(), and Packet::Recv_uint8().
Referenced by ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(), ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(), ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(), and NetworkUDPSocketHandler::ReceiveNetworkGameInfo().
| void NetworkSocketHandler::SendCompanyInformation | ( | Packet * | p, | 
| const struct Company * | c, | ||
| const struct NetworkCompanyStats * | stats, | ||
| uint | max_len = NETWORK_COMPANY_NAME_LENGTH | ||
| ) | 
Package some generic company information into a packet.
| p | The packet that will contain the data. | 
| c | The company to put the of into the packet. | 
| stats | The statistics to put in the packet. | 
| max_len | The maximum length of the company name. | 
Definition at line 1514 of file network_server.cpp.
References _cur_year, _network_company_states, CompanyEconomyEntry::company_value, CompanyProperties::inaugurated_year, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, CompanyProperties::is_ai, lengthof, CompanyProperties::money, NETWORK_COMPANY_NAME_LENGTH, NetworkCompanyStats::num_station, NetworkCompanyStats::num_vehicle, CompanyProperties::old_economy, NetworkCompanyState::password, CompanyEconomyEntry::performance_history, Packet::Send_bool(), Packet::Send_string(), Packet::Send_uint16(), Packet::Send_uint32(), Packet::Send_uint64(), Packet::Send_uint8(), SetDParam(), StrEmpty(), and CompanyProperties::yearly_expenses.
Referenced by ServerNetworkUDPSocketHandler::Receive_CLIENT_DETAIL_INFO(), and ServerNetworkGameSocketHandler::SendCompanyInfo().
| void NetworkSocketHandler::SendGRFIdentifier | ( | 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 108 of file core.cpp.
References GRFIdentifier::grfid, GRFIdentifier::md5sum, Packet::Send_uint32(), and Packet::Send_uint8().
Referenced by ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(), ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(), NetworkUDPSocketHandler::SendNetworkGameInfo(), and ServerNetworkGameSocketHandler::SendNewGRFCheck().
 1.8.1.2
 1.8.1.2