/* */ #ifndef _D_DHT_CONNECTION_IMPL_H_ #define _D_DHT_CONNECTION_IMPL_H_ #include "DHTConnection.h" #include "SharedHandle.h" #include "IntSequence.h" namespace aria2 { class SocketCore; class Logger; class DHTConnectionImpl:public DHTConnection { private: SharedHandle _socket; Logger* _logger; public: DHTConnectionImpl(); virtual ~DHTConnectionImpl(); /** * Binds port. All number in ports are tried. * If successful, the binded port is assigned to port and returns true. * Otherwise return false and port is undefined in this case. */ bool bind(uint16_t& port, IntSequence& ports); /** * Binds port. The port number specified by port is used to bind. * If successful, the binded port is assigned to port and returns true. * Otherwise return false and port is undefined in this case. * * If you want to bind arbitrary port, give 0 as port and if successful, * the binded port is assigned to port. */ bool bind(uint16_t& port); virtual ssize_t receiveMessage(unsigned char* data, size_t len, std::string& host, uint16_t& port); virtual void sendMessage(const unsigned char* data, size_t len, const std::string& host, uint16_t port); SharedHandle getSocket() const; }; } // namespace aria2 #endif // _D_DHT_CONNECTION_IMPL_H_