Belle II Software development
Sock2Rb Class Reference

Public Member Functions

 Sock2Rb (std::string rbuf, int port)
 Constuctor and Destructor.
 
int ReceiveEvent (void)
 Event function.
 

Private Attributes

RingBufferm_rbuf
 
EvtSocketRecvm_sock
 
char * m_evtbuf
 

Detailed Description

Definition at line 23 of file Sock2Rb.h.

Constructor & Destructor Documentation

◆ Sock2Rb()

Sock2Rb ( std::string  rbuf,
int  port 
)

Constuctor and Destructor.

Definition at line 16 of file Sock2Rb.cc.

17{
18 // m_rbuf = new RingBuffer(rbuf.c_str(), RBUFSIZE);
19 m_rbuf = new RingBuffer(rbuf.c_str());
20 m_sock = new EvtSocketRecv(port);
21 m_evtbuf = new char[MAXEVTSIZE];
22
23}
Class to manage a Ring Buffer placed in an IPC shared memory.
Definition: RingBuffer.h:39

◆ ~Sock2Rb()

~Sock2Rb ( void  )

Definition at line 25 of file Sock2Rb.cc.

26{
27 delete m_sock;
28 delete m_rbuf;
29}

Member Function Documentation

◆ ReceiveEvent()

int ReceiveEvent ( void  )

Event function.

Definition at line 31 of file Sock2Rb.cc.

32{
33 // Get a record from socket
34 EvtMessage* msg = m_sock->recv();
35 if (msg == NULL) {
36 return 0;
37 }
38 // B2INFO ( "Rx: got an event from Socket, size=" << msg->size() );
39 if (msg->type() == MSG_TERMINATE) {
40 return 0;
41 // Flag End Of File !!!!!
42 // return msg->type(); // EOF
43 }
44
45 // Put the message in ring buffer
46 int stat = 0;
47 for (;;) {
48 stat = m_rbuf->insq((int*)msg->buffer(), msg->paddedSize());
49 if (stat >= 0) break;
50 // usleep(100);
51 usleep(20);
52 }
53 delete msg;
54 return stat;
55}
Class to manage streamed object.
Definition: EvtMessage.h:59
int paddedSize() const
Same as size(), but as size of an integer array.
Definition: EvtMessage.cc:99
ERecordType type() const
Get record type.
Definition: EvtMessage.cc:114
char * buffer()
Get buffer address.
Definition: EvtMessage.cc:76
int insq(const int *buf, int size, bool checkTx=false)
Append a buffer to the RingBuffer.
Definition: RingBuffer.cc:189

Member Data Documentation

◆ m_evtbuf

char* m_evtbuf
private

Definition at line 35 of file Sock2Rb.h.

◆ m_rbuf

RingBuffer* m_rbuf
private

Definition at line 33 of file Sock2Rb.h.

◆ m_sock

EvtSocketRecv* m_sock
private

Definition at line 34 of file Sock2Rb.h.


The documentation for this class was generated from the following files: