(svn r15971) -Codechange: make it possible for UDP socket handlers to bind to multiple sockets.

This commit is contained in:
rubidium
2009-04-07 20:27:13 +00:00
parent 6db7f15b3a
commit 2a6e9288fd
7 changed files with 103 additions and 94 deletions

View File

@@ -96,6 +96,11 @@ enum PacketUDPType {
/** Base socket handler for all UDP sockets */
class NetworkUDPSocketHandler : public NetworkSocketHandler {
protected:
/** The address to bind to. */
NetworkAddressList bind;
/** The opened sockets. */
SocketList sockets;
NetworkRecvStatus CloseConnection();
/* Declare all possible packets here. If it can be received by the
@@ -124,13 +129,15 @@ protected:
*/
virtual void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config) { NOT_REACHED(); }
public:
NetworkUDPSocketHandler(NetworkAddressList *bind = NULL);
/** On destructing of this class, the socket needs to be closed */
virtual ~NetworkUDPSocketHandler() { this->Close(); }
bool Listen(NetworkAddress address, bool broadcast);
bool Listen();
void Close();
void SendPacket(Packet *p, NetworkAddress *recv);
void SendPacket(Packet *p, NetworkAddress *recv, bool all = false, bool broadcast = false);
void ReceivePackets();
void Send_NetworkGameInfo(Packet *p, const NetworkGameInfo *info);