MPMA Framework 0.4
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 "../base/Setup.h"
00008 
00009 #ifdef MPMA_COMPILE_NET
00010 
00011 #include "Common.h"
00012 
00013 #include <vector>
00014 
00015 class MPMAMemoryManager; //FD
00016 
00017 namespace NET
00018 {
00020     class UDPClient
00021     {
00022     public:
00024         static UDPClient* Create(uint16 localPort=0, bool allowBroadcast=false, bool openNatAutomatically=true);
00025 
00027         static void FreeClient(UDPClient *client);
00028 
00030         bool Send(const Address &addr, const void *data, nuint dataLen);
00031 
00033         inline uint16 GetLocalPort() const
00034             { return localPortUsed; }
00035 
00037         bool Receive(std::vector<uint8> &data, Address *source=0);
00038 
00039         //TODO: callback system for data coming in
00040 
00041     private:
00042         //we are the only allocator
00043         UDPClient();
00044         inline ~UDPClient() {}
00045         inline UDPClient(const UDPClient&) {}
00046         inline void operator=(const UDPClient&) {}
00047         friend class ::MPMAMemoryManager;
00048 
00049         //
00050         nsint sock;
00051         uint16 localPortUsed;
00052         bool isInBlockingMode;
00053         bool autoUPNP;
00054     };
00055 }
00056 
00057 #endif //#ifdef MPMA_COMPILE_NET
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends