UDP.h

Go to the documentation of this file.
00001 
00002 //written by Luke Lenhart, 2008
00003 //See /docs/License.txt for details on how this code may be used.
00004 
00005 #pragma once
00006 
00007 #include "Common.h"
00008 #include <vector>
00009 
00010 class MPMAMemoryManager; //FD
00011 
00012 namespace NET
00013 {
00015     class UDPClient
00016     {
00017     public:
00019         static UDPClient* Create(uint16 localPort=0, bool allowBroadcast=false, bool openNatAutomatically=true);
00020 
00022         static void FreeClient(UDPClient *client);
00023 
00025         bool Send(const Address &addr, const void *data, uint dataLen);
00026 
00028         inline uint16 GetLocalPort() const
00029             { return localPortUsed; }
00030 
00032         bool Receive(std::vector<uint8> &data, Address *source=0);
00033 
00034         //TODO: callback system for data coming in
00035 
00036     private:
00037         //we are the only allocator
00038         UDPClient();
00039         inline ~UDPClient() {}
00040         inline UDPClient(const UDPClient&) {}
00041         inline void operator=(const UDPClient&) {}
00042         friend class ::MPMAMemoryManager;
00043 
00044         //
00045         int sock;
00046         uint16 localPortUsed;
00047         bool isInBlockingMode;
00048         bool autoUPNP;
00049     };
00050 }

Generated on Sat Aug 9 15:05:05 2008 for MPMA Framework by  doxygen 1.5.6