/* */ #ifndef BACKUP_IPV4_CONNECT_COMMAND_H #define BACKUP_IPV4_CONNECT_COMMAND_H #include "Command.h" #include #include #include "TimerA2.h" namespace aria2 { class RequestGroup; class DownloadEngine; class SocketCore; // Used to communicate mainCommand and backup IPv4 connection command. // When backup connection succeeds, ipaddr is filled with connected // IPv4 address and socket is a socket connected to the ipaddr. If // mainCommand wants to cancel backup connection command, cancel // member becomes true. struct BackupConnectInfo { std::string ipaddr; std::shared_ptr socket; bool cancel; BackupConnectInfo(); }; // Make backup connection to IPv4 address. This is a simplest RFC 6555 // "Happy Eyeballs" implementation. class BackupIPv4ConnectCommand : public Command { public: BackupIPv4ConnectCommand(cuid_t cuid, const std::string& ipaddr, uint16_t port, const std::shared_ptr& info, Command* mainCommand, RequestGroup* requestGroup, DownloadEngine* e); ~BackupIPv4ConnectCommand(); virtual bool execute() CXX11_OVERRIDE; private: std::string ipaddr_; uint16_t port_; std::shared_ptr socket_; std::shared_ptr info_; Command* mainCommand_; RequestGroup* requestGroup_; DownloadEngine* e_; Timer startTime_; Timer timeoutCheck_; std::chrono::seconds timeout_; }; } // namespace aria2 #endif // BACKUP_IPV4_CONNECT_COMMAND_H