summaryrefslogtreecommitdiff
path: root/src/network/core/udp.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-01-12 20:19:49 +0000
committerrubidium <rubidium@openttd.org>2007-01-12 20:19:49 +0000
commitf66b373b52b2daef69507c402577a1a02b65c40b (patch)
tree23bff1b129004614fd68cb0c30436a14bbe240e9 /src/network/core/udp.h
parentee1021d29c6baa6380faf17e270fd5194d2b330c (diff)
downloadopenttd-f66b373b52b2daef69507c402577a1a02b65c40b.tar.xz
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
Diffstat (limited to 'src/network/core/udp.h')
-rw-r--r--src/network/core/udp.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/network/core/udp.h b/src/network/core/udp.h
index 755829600..9bb743841 100644
--- a/src/network/core/udp.h
+++ b/src/network/core/udp.h
@@ -6,11 +6,11 @@
#ifdef ENABLE_NETWORK
#include "os_abstraction.h"
+#include "core.h"
#include "game.h"
#include "packet.h"
#include "../../newgrf_config.h"
#include "../../debug.h"
-#include "../network_data.h"
/**
* @file udp.h Basic functions to receive and send UDP packets.
@@ -91,11 +91,11 @@ enum PacketUDPType {
#define DECLARE_UDP_RECEIVE_COMMAND(type) virtual void NetworkPacketReceive_## type ##_command(Packet *p, const struct sockaddr_in *)
-class NetworkUDPSocketHandler {
-private:
- SOCKET udp;
+/** Base socket handler for all UDP sockets */
+class NetworkUDPSocketHandler : public NetworkSocketHandler {
protected:
- NetworkClientState cs;
+ NetworkRecvStatus CloseConnection();
+
/* Declare all possible packets here. If it can be received by the
* a specific handler, it has to be implemented. */
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_FIND_SERVER);
@@ -121,10 +121,8 @@ protected:
*/
virtual void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config) { NOT_REACHED(); }
public:
- NetworkUDPSocketHandler();
virtual ~NetworkUDPSocketHandler() { this->Close(); }
- bool IsListening() { return this->udp != INVALID_SOCKET; }
bool Listen(uint32 host, uint16 port, bool broadcast);
void Close();