iomanager.hpp 615 B

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