38 lines
673 B
C++
38 lines
673 B
C++
#ifndef CHECKS_PARSER_HTTP_SERVER
|
|
#define CHECKS_PARSER_HTTP_SERVER
|
|
|
|
#include <netinet/in.h>
|
|
#include <QWidget>
|
|
#include <thread>
|
|
#include <vector>
|
|
|
|
|
|
class HttpServer {
|
|
private:
|
|
unsigned short port;
|
|
int serverSocket;
|
|
sockaddr_in serverAddress;
|
|
|
|
QWidget* caller;
|
|
|
|
std::thread listenClientsThread;
|
|
std::vector<std::thread> clientHandlersThreads;
|
|
|
|
bool started;
|
|
|
|
void generateRandomPort();
|
|
public:
|
|
HttpServer(QWidget *caller);
|
|
~HttpServer();
|
|
int start();
|
|
void stop();
|
|
void handleClient(int clientSocket);
|
|
void acceptClients();
|
|
|
|
unsigned short getPort();
|
|
|
|
bool isStarted();
|
|
};
|
|
|
|
#endif //CHECKS_PARSER_HTTP_SERVER
|