tdaq-develop-2025-02-12
TCPServer.h
1 #ifndef _ots_TCPServer_h_
2 #define _ots_TCPServer_h_
3 
4 #include <iostream>
5 #include <string>
6 #include "otsdaq/NetworkUtilities/TCPServerBase.h"
7 
8 namespace ots
9 {
10 class TCPTransceiverSocket;
11 
12 class TCPServer : public TCPServerBase
13 {
14  public:
15  TCPServer(unsigned int serverPort, unsigned int maxNumberOfClients = -1);
16  virtual ~TCPServer(void);
17 
18  virtual std::string interpretMessage(const std::string& buffer) = 0;
19  void setReceiveTimeout(unsigned int timeoutSeconds, unsigned int timeoutMicroseconds);
20  void setSendTimeout(unsigned int timeoutSeconds, unsigned int timeoutMicroseconds);
21 
22  private:
23  void acceptConnections(void) override;
24  void connectClient(TCPTransceiverSocket* clientSocket);
25  struct timeval fReceiveTimeout;
26  struct timeval fSendTimeout;
27  bool fInDestructor;
28 };
29 } // namespace ots
30 
31 #endif
A class that can read/write to a socket.