You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
651 B

  1. #ifndef __BETACORE_SERVER_HPP__
  2. #define __BETACORE_SERVER_HPP__
  3. #include <vector>
  4. #include <sys/types.h>
  5. #include <sys/socket.h>
  6. #include <netinet/in.h>
  7. #include <thread>
  8. #include <utility>
  9. #include <functional>
  10. namespace betacore
  11. {
  12. class Server
  13. {
  14. private:
  15. bool online = false;
  16. bool server_running= false;
  17. int port;
  18. int server_socket;
  19. std::vector<int> clients;
  20. char buffer[1024];
  21. struct sockaddr_in server_address;
  22. std::vector<sockaddr_in> client_socket_collection;
  23. void start();
  24. void shutdown();
  25. void listener();
  26. void read_socket(int client);
  27. public:
  28. Server(int port);
  29. void off();
  30. bool running();
  31. };
  32. } // namespace betacore
  33. #endif