// This file is part of Timmi. // // Timmi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. #ifndef TCPCLIENT_HH #define TCPCLIENT_HH #include class TCPClient { public: TCPClient(); ~TCPClient(); // Connect to remote host. // Returns true if succeeded. bool connect_socket(std::string host, int port); bool good() const; // Wait for event or error for timeout milliseconds (-1 == forever) // Return false if timeouted bool wait_for_event(int timeout = -1) const; // Send line void send_line(std::string line); // Handle received line // Default one prints debug message with level VERBOSE virtual void handle_line(std::string line); // Default main loop handler // Waits for events without timeout and handles them virtual void mainloop(); // Process messages, part of mainloop void do_main(); protected: TCPSocket *socket_; }; #endif