CMS 3D CMS Logo

TCPReceiver.h
Go to the documentation of this file.
1 /*
2  Author: Adam Hunt
3  email: ahunt@princeton.edu
4  Date: 2007-08-24
5 */
6 
7 /*
8  Error Codes
9  0: unknown failure
10  1: success
11  101: invalid port
12  iana.org registers ports from 0 - 1023
13  201: invalid mode
14  Acceptable modes are 0: tcp data, 1: constant fake data, 2: random fake data
15  301: socket() failed
16  302: connect() failed
17  401: Disconnect() called without being connected
18  501: Failed to Receive Data from server
19  601; close() failed
20 
21 TODO: This should be changed to errno.
22 
23 */
24 
25 #ifndef HLXTCP_H
26 #define HLXTCP_H
27 
28 #include <string>
29 #include <netinet/in.h> // struct sockaddr_in
30 
31 namespace HCAL_HLX {
32 
33  struct LUMI_SECTION;
34 
35  class TCPReceiver {
36  public:
37  TCPReceiver();
38  TCPReceiver(unsigned short int, std::string, unsigned char);
39  ~TCPReceiver();
40  int Connect();
41  int SetPort(unsigned short int);
42  int SetMode(unsigned char);
43  void SetIP(std::string IP);
44  int ReceiveLumiSection(HCAL_HLX::LUMI_SECTION& localSection);
45  int Disconnect();
46  bool IsConnected();
47  bool VerifyFakeData(HCAL_HLX::LUMI_SECTION& localSection);
48 
49  void GenerateFakeData(HCAL_HLX::LUMI_SECTION& localSection);
50  void GenerateRandomData(HCAL_HLX::LUMI_SECTION& localSection);
51 
52  private:
53  unsigned char acquireMode;
54  bool Connected;
55 
56  unsigned short servPort;
58  int tcpSocket;
59  struct sockaddr_in servAddr;
60  };
61 } // namespace HCAL_HLX
62 
63 #endif
unsigned char acquireMode
Definition: TCPReceiver.h:53
int SetPort(unsigned short int)
Definition: TCPReceiver.cc:179
void SetIP(std::string IP)
Definition: TCPReceiver.cc:219
void GenerateRandomData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:388
void GenerateFakeData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:310
int ReceiveLumiSection(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:87
std::string servIP
Definition: TCPReceiver.h:57
int SetMode(unsigned char)
Definition: TCPReceiver.cc:199
unsigned short servPort
Definition: TCPReceiver.h:56
struct sockaddr_in servAddr
Definition: TCPReceiver.h:59
bool VerifyFakeData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:462