tdaq-develop-2025-02-12
Socket.h
1 #ifndef _ots_Socket_h_
2 #define _ots_Socket_h_
3 
4 #include <netinet/in.h>
5 #include <sys/types.h>
6 #include <string>
7 
8 namespace ots
9 {
10 class Socket
11 {
12  public:
13  Socket(const std::string& IPAddress, unsigned int port = 0);
14  virtual ~Socket(void);
15 
16  virtual void initialize(
17  unsigned int socketReceiveBufferSize = defaultSocketReceiveSize_);
18  const struct sockaddr_in& getSocketAddress(void);
19  const std::string& getIPAddress() { return IPAddress_; }
20  uint16_t getPort();
21 
22  protected:
23  enum
24  {
25  maxSocketSize_ = 65536,
26  defaultSocketReceiveSize_ = 0x10000
27  };
28 
29  Socket(void);
30  struct sockaddr_in socketAddress_;
31  int socketNumber_;
32  // unsigned int maxSocketSize_;
33 
34  protected:
35  enum
36  {
37  FirstSocketPort = 10000,
38  LastSocketPort = 15000
39  };
40  std::string IPAddress_;
41  unsigned int requestedPort_;
42 };
43 
44 } // namespace ots
45 
46 #endif
Socket(void)
protected constructor
Definition: Socket.cc:62