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 MemMan; //FD
00011 
00012 namespace NET
00013 {
00015     class UDPReceiver
00016     {
00017     public:
00019         static UDPReceiver* CreateReceiver(uint16 port);
00020 
00022         static void FreeReceiver(UDPReceiver *receiver);
00023 
00025         bool Receive(std::vector<uint8> &data, Address *source=0);
00026 
00028         inline uint16 GetPort() const { return port; }
00029 
00030         //TODO: Callback mechanism to notify when data is recieved so they don't have to poll.
00031 
00032     private:
00033         //we are the only allocator
00034         UDPReceiver();
00035         inline ~UDPReceiver() {}
00036         inline UDPReceiver(const UDPReceiver&) {}
00037         inline void operator=(const UDPReceiver&) {}
00038         friend class ::MemMan;
00039 
00040         //
00041         int sock;
00042         uint16 port;
00043     };
00044 
00046     class UDPSender
00047     {
00048     public:
00050         static UDPSender* CreateSender();
00051 
00053         static void FreeSender(UDPSender *sender);
00054 
00056         bool Send(const Address &addr, const void *data, uint dataLen);
00057 
00058     private:
00059         //we are the only allocator
00060         UDPSender();
00061         inline ~UDPSender() {}
00062         inline UDPSender(const UDPSender&) {}
00063         inline void operator=(const UDPSender&) {}
00064         friend class ::MemMan;
00065 
00066         //
00067         int sock;
00068     };
00069 }

Generated on Wed Feb 13 20:57:04 2008 for MPMA Framework by  doxygen 1.5.4