SockIt

UdpServer.h

Go to the documentation of this file.
00001 #ifndef UDPSERVER_H
00002 #define UDPSERVER_H
00003 
00004 #include <string>
00005 
00006 #include <boost/asio.hpp>
00007 #include <boost/bind.hpp>
00008 #include <boost/thread.hpp>
00009 
00010 #include "Udp.h"
00011 #include "Server.h"
00012 #include "Logger.h"
00013 #include "Event.h"
00014 #include "UdpEvent.h"
00015 
00016 using boost::asio::ip::udp;
00017 
00018 class UdpServer;
00019 class UdpEvent;
00020 
00025 class UdpServer: public Udp, public Server
00026 {
00027     public:
00028 
00037         UdpServer(int port, boost::asio::io_service & io_service);
00038 
00048         UdpServer(int port, boost::asio::io_service & io_service, map<string, string> options);
00049 
00053         ~UdpServer();
00054 
00060         virtual void start_listening();
00061 
00066         virtual void shutdown();
00067 
00071         virtual int get_port();
00072 
00073         friend class UdpEvent;
00074 
00075     protected:
00076 
00082         virtual void fire_error_event(const string & message);
00083 
00091         virtual void fire_data_event(const string data, boost::shared_ptr<udp::socket> socket, boost::shared_ptr<udp::endpoint> endpoint);
00092 
00096         virtual void close();
00097 
00098     private:
00099 
00103         UdpServer(const UdpServer &other);
00104 
00109         void initialize(void);
00110 
00114         virtual void listen(void);
00115 
00119          boost::shared_ptr<udp::socket> socket;
00120 
00122         bool listening;
00123 };
00124 
00125 #endif
 All Classes Files Functions Variables Typedefs Friends Defines