iomanager.hpp 604 B

12345678910111213141516171819202122232425262728
  1. #ifndef IOMANAGER_HPP
  2. #define IOMANAGER_HPP
  3. #include <string>
  4. #include <boost/asio.hpp>
  5. using boost::asio::ip::tcp;
  6. class IoManager {
  7. protected:
  8. boost::asio::streambuf recvbuf;
  9. boost::asio::io_service ios;
  10. tcp::socket *tcpsock;
  11. boost::system::error_code errcode;
  12. std::string *ipstring;
  13. int port;
  14. public:
  15. // Basic constructor
  16. IoManager(char *ipcstring);
  17. // destructor to clean up all generic stuff
  18. ~IoManager();
  19. // enters loop to handle further interaction based on derived class
  20. virtual void run() = 0;
  21. // tries to establish connection, returns false on error
  22. bool connect();
  23. };
  24. #endif