/* */ #ifndef D_LPD_MESSAGE_RECEIVER_H #define D_LPD_MESSAGE_RECEIVER_H #include "common.h" #include #include namespace aria2 { class SocketCore; struct LpdMessage; class LpdMessageReceiver { private: std::shared_ptr socket_; std::string multicastAddress_; uint16_t multicastPort_; std::string localAddress_; public: // Currently only IPv4 multicastAddresses are supported. LpdMessageReceiver(const std::string& multicastAddress, uint16_t multicastPort); ~LpdMessageReceiver(); // No throw. bool init(const std::string& localAddr); // Receives LPD message and returns LpdMessage which contains // sender(peer) and infohash. If no data is available on socket, // returns std::shared_ptr(). If received data is bad, // they are just skipped. std::unique_ptr receiveMessage(); const std::shared_ptr& getSocket() const { return socket_; } const std::string& getLocalAddress() const { return localAddress_; } }; } // namespace aria2 #endif // D_LPD_MESSAGE_RECEIVER_H