CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 /*
9  Error Codes
10  0: unknown failure
11  1: success
12  101: invalid port
13  iana.org registers ports from 0 - 1023
14  201: invalid mode
15  Acceptable modes are 0: tcp data, 1: constant fake data, 2: random fake data
16  301: socket() failed
17  302: connect() failed
18  401: Disconnect() called without being connected
19  501: Failed to Receive Data from server
20  601; close() failed
21 
22 TODO: This should be changed to errno.
23 
24 */
25 
26 #ifndef HLXTCP_H
27 #define HLXTCP_H
28 
29 #include <string>
30 #include <netinet/in.h> // struct sockaddr_in
31 
32 namespace HCAL_HLX{
33 
34  struct LUMI_SECTION;
35 
36  class TCPReceiver{
37 
38  public:
39  TCPReceiver();
40  TCPReceiver(unsigned short int, std::string, unsigned char);
41  ~TCPReceiver();
42  int Connect();
43  int SetPort(unsigned short int);
44  int SetMode(unsigned char);
45  void SetIP(std::string IP);
46  int ReceiveLumiSection(HCAL_HLX::LUMI_SECTION & localSection);
47  int Disconnect();
48  bool IsConnected();
49  bool VerifyFakeData(HCAL_HLX::LUMI_SECTION & localSection);
50 
51  void GenerateFakeData(HCAL_HLX::LUMI_SECTION & localSection);
52  void GenerateRandomData(HCAL_HLX::LUMI_SECTION & localSection);
53 
54  private:
55  unsigned char acquireMode;
56  bool Connected;
57 
58  unsigned short servPort;
59  std::string servIP;
60  int tcpSocket;
61  struct sockaddr_in servAddr;
62  };
63 }
64 
65 #endif
unsigned char acquireMode
Definition: TCPReceiver.h:55
int SetPort(unsigned short int)
Definition: TCPReceiver.cc:182
void SetIP(std::string IP)
Definition: TCPReceiver.cc:222
void GenerateRandomData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:395
void GenerateFakeData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:316
int ReceiveLumiSection(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:88
std::string servIP
Definition: TCPReceiver.h:59
int SetMode(unsigned char)
Definition: TCPReceiver.cc:202
unsigned short servPort
Definition: TCPReceiver.h:58
struct sockaddr_in servAddr
Definition: TCPReceiver.h:61
bool VerifyFakeData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:469