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
HCAL_HLX::LUMI_SECTION
Definition: LumiRawDataStructures.h:285
HCAL_HLX::TCPReceiver::Connect
int Connect()
Definition: TCPReceiver.cc:229
HCAL_HLX::TCPReceiver::GenerateFakeData
void GenerateFakeData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:310
HCAL_HLX
Definition: LumiRawDataStructures.h:18
HCAL_HLX::TCPReceiver::ReceiveLumiSection
int ReceiveLumiSection(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:87
HCAL_HLX::TCPReceiver::~TCPReceiver
~TCPReceiver()
Definition: TCPReceiver.cc:63
HCAL_HLX::TCPReceiver
Definition: TCPReceiver.h:35
HCAL_HLX::TCPReceiver::tcpSocket
int tcpSocket
Definition: TCPReceiver.h:58
HCAL_HLX::TCPReceiver::IsConnected
bool IsConnected()
Definition: TCPReceiver.cc:172
HCAL_HLX::TCPReceiver::servPort
unsigned short servPort
Definition: TCPReceiver.h:56
HCAL_HLX::TCPReceiver::SetIP
void SetIP(std::string IP)
Definition: TCPReceiver.cc:219
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HCAL_HLX::TCPReceiver::acquireMode
unsigned char acquireMode
Definition: TCPReceiver.h:53
HCAL_HLX::TCPReceiver::servAddr
struct sockaddr_in servAddr
Definition: TCPReceiver.h:59
listHistos.IP
IP
Definition: listHistos.py:76
HCAL_HLX::TCPReceiver::SetPort
int SetPort(unsigned short int)
Definition: TCPReceiver.cc:179
HCAL_HLX::TCPReceiver::VerifyFakeData
bool VerifyFakeData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:462
HCAL_HLX::TCPReceiver::SetMode
int SetMode(unsigned char)
Definition: TCPReceiver.cc:199
HCAL_HLX::TCPReceiver::Connected
bool Connected
Definition: TCPReceiver.h:54
HCAL_HLX::TCPReceiver::TCPReceiver
TCPReceiver()
Definition: TCPReceiver.cc:34
HCAL_HLX::TCPReceiver::Disconnect
int Disconnect()
Definition: TCPReceiver.cc:283
HCAL_HLX::TCPReceiver::GenerateRandomData
void GenerateRandomData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:388
HCAL_HLX::TCPReceiver::servIP
std::string servIP
Definition: TCPReceiver.h:57