|
1234567891011121314151617181920212223 |
- #ifndef TCPSERVER_H
- #define TCPSERVER_H
-
- #include <functional>
-
- class TcpServer
- {
- public:
- TcpServer();
- typedef std::function<void (int socket)> ClientHandler;
- public:
- bool start(int port);
- void whenNewClient(ClientHandler onClientConnected);
- void stop();
- private:
- void keepAccept();
- private:
- ClientHandler mClientHandler;
- bool mStarted=false;
- int mSocket;
- };
-
- #endif // TCPSERVER_H
|