Belle II Software development
HistoRelay.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include "daq/dqm/HistoRelay.h"
10#include <framework/pcore/EvtMessage.h>
11
12using namespace Belle2;
13using namespace std;
14
15HistoRelay::HistoRelay(string& file, string& dest, int port)
16{
17 m_dest = dest;
18 m_port = port;
19 m_memfile = new DqmMemFile(file);
20 m_sock = new EvtSocketSend(m_dest, m_port);
21}
22
23HistoRelay::~HistoRelay()
24{
25 delete m_sock;
26 delete m_memfile;
27}
28
29int HistoRelay::collect()
30{
31 // printf ( "HistoRelay : collect!!\n" );
32 EvtMessage* msg = m_memfile->StreamMemFile();
33
34 auto ret = m_sock->send(msg);
35
36 delete (msg);
37
38 if (ret < 0) {
39 // Socket error, e.g server died
40 delete m_sock;
41 // try reconnect
42 printf("HistoRelay: socket seems dead -> reconnect\n");
43 m_sock = new EvtSocketSend(m_dest, m_port);
44 }
45
46 return 0;
47}
Class to manage streamed object.
Definition: EvtMessage.h:59
Abstract base class for different kinds of events.
STL namespace.