HTTPServer.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. /*
  7. * File: HTTPServer.h
  8. * Author: root
  9. *
  10. * Created on November 5, 2016, 5:46 PM
  11. */
  12. #ifndef HTTPSERVER_H
  13. #define HTTPSERVER_H
  14. #include <list>
  15. #include "ServerThread.h"
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <unistd.h>
  20. #include <sys/types.h>
  21. #include <sys/socket.h>
  22. #include <netinet/in.h>
  23. #include <arpa/inet.h>
  24. #include <string>
  25. #include <iostream>
  26. using namespace std;
  27. class HTTPServer {
  28. public:
  29. HTTPServer(int port);
  30. HTTPServer(const HTTPServer& orig);
  31. virtual ~HTTPServer();
  32. void RunServer();
  33. void RunTerminator();
  34. void StartServer();
  35. void StartTerminator();
  36. void Stop();
  37. private:
  38. pthread_t server, terminator;
  39. // a list of active clients
  40. list<ServerThread*> aclients;
  41. // socket fields
  42. int sockfd, portno;
  43. sockaddr_in serv_addr, cli_addr;
  44. socklen_t clilen;
  45. };
  46. #endif /* HTTPSERVER_H */