stk-code_catmod/dev/SocketsBase/stk_host.hpp
hilnius 1cac3c7815 improving socket management
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@12870 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2013-06-17 18:06:02 +00:00

41 lines
1.1 KiB
C++

#ifndef STK_HOST_HPP
#define STK_HOST_HPP
#include <enet/enet.h>
class STKHost
{
friend class STKPeer;
public:
enum HOST_TYPE
{
HOST_ANY = 0,
HOST_BROADCAST = 0xFFFFFFFF,
PORT_ANY = 0
};
STKHost();
virtual ~STKHost();
static void* receive_data(void* self);
void setupServer(uint32_t address, uint16_t port, int peerCount, int channelLimit, uint32_t maxIncomingBandwidth, uint32_t maxOutgoingBandwidth);
void setupClient(int peerCount, int channelLimit, uint32_t maxIncomingBandwidth, uint32_t maxOutgoingBandwidth);
void startListening();
void stopListening();
void sendRawPacket(uint8_t* data, int length, unsigned int dstIp, unsigned short dstPort);
uint8_t* receiveRawPacket();
uint8_t* receiveRawPacket(unsigned int dstIp, unsigned short dstPort);
void broadcastPacket(char* data);
protected:
ENetHost* m_host;
pthread_t* m_listeningThread;
};
#endif // STK_HOST_HPP