otsdaq  v2_05_02_indev
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(unsigned int socketReceiveBufferSize = defaultSocketReceiveSize_);
17  const struct sockaddr_in& getSocketAddress(void);
18  const std::string& getIPAddress() { return IPAddress_; }
19  uint16_t getPort();
20 
21  protected:
22  enum
23  {
24  maxSocketSize_ = 65536,
25  defaultSocketReceiveSize_ = 0x10000
26  };
27 
28  Socket(void);
29  struct sockaddr_in socketAddress_;
30  int socketNumber_;
31  // unsigned int maxSocketSize_;
32 
33  protected:
34  enum
35  {
36  FirstSocketPort = 10000,
37  LastSocketPort = 15000
38  };
39  std::string IPAddress_;
40  unsigned int requestedPort_;
41 };
42 
43 } // namespace ots
44 
45 #endif