UniSet  2.6.0
UDPCore.h
00001 // -------------------------------------------------------------------------
00002 #ifndef UDPReceiveU_H_
00003 #define UDPReceiveU_H_
00004 // -------------------------------------------------------------------------
00005 #include <Poco/Net/DatagramSocket.h>
00006 // -------------------------------------------------------------------------
00007 // Классы-обёртки, чтобы достучаться до "сырого сокета" и других функций
00008 // необходимых при использовании с libev..
00009 // -------------------------------------------------------------------------
00010 namespace uniset
00011 {
00012 
00013 class UDPSocketU:
00014     public Poco::Net::DatagramSocket
00015 {
00016     public:
00017 
00018         UDPSocketU():
00019             Poco::Net::DatagramSocket(Poco::Net::IPAddress::IPv4)
00020         {}
00021 
00022         UDPSocketU( const std::string& bind, int port ):
00023             Poco::Net::DatagramSocket(Poco::Net::SocketAddress(bind, port), true)
00024         {}
00025 
00026         virtual ~UDPSocketU() {}
00027 
00028         inline int getSocket() const
00029         {
00030             return Poco::Net::DatagramSocket::sockfd();
00031         }
00032 };
00033 // -------------------------------------------------------------------------
00034 class UDPReceiveU:
00035     public Poco::Net::DatagramSocket
00036 {
00037     public:
00038 
00039         UDPReceiveU():
00040             Poco::Net::DatagramSocket(Poco::Net::IPAddress::IPv4)
00041         {}
00042 
00043         UDPReceiveU( const std::string& bind, int port):
00044             Poco::Net::DatagramSocket(Poco::Net::SocketAddress(bind, port), true)
00045         {}
00046 
00047         virtual ~UDPReceiveU() {}
00048 
00049         inline int getSocket()
00050         {
00051             return Poco::Net::DatagramSocket::sockfd();
00052         }
00053 };
00054 // -------------------------------------------------------------------------
00055 } // end of uniset namespace
00056 // -------------------------------------------------------------------------
00057 #endif // UDPReceiveU_H_
00058 // -------------------------------------------------------------------------