Belle II Software  release-05-02-19
LogConnectionUDP.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <framework/logging/LogConnectionBase.h>
13 #include <boost/asio.hpp>
14 
15 namespace Belle2 {
23  class LogConnectionUDP final: public LogConnectionBase {
24  public:
26  LogConnectionUDP(const std::string& hostname, unsigned short port);
28  ~LogConnectionUDP() override;
30  bool sendMessage(const LogMessage& message) final;
32  bool isConnected() final;
33  private:
35  boost::asio::io_service m_ioservice;
37  boost::asio::ip::udp::socket m_socket;
39  boost::asio::ip::udp::endpoint m_remoteEndpoint;
40  };
42 }
Belle2::LogConnectionUDP::isConnected
bool isConnected() final
there is no way to check if a UDP connection is fine, so we just return True always
Definition: LogConnectionUDP.cc:29
Belle2::LogConnectionUDP::sendMessage
bool sendMessage(const LogMessage &message) final
Send the log message as JSON to the UDP server.
Definition: LogConnectionUDP.cc:34
Belle2::LogConnectionUDP::m_ioservice
boost::asio::io_service m_ioservice
asio service for handling the requests
Definition: LogConnectionUDP.h:43
Belle2::LogConnectionUDP::~LogConnectionUDP
~LogConnectionUDP() override
Close the socket on destruction.
Definition: LogConnectionUDP.cc:44
Belle2::LogConnectionUDP::m_remoteEndpoint
boost::asio::ip::udp::endpoint m_remoteEndpoint
the remote endpoint we send to
Definition: LogConnectionUDP.h:47
Belle2::LogConnectionUDP::LogConnectionUDP
LogConnectionUDP(const std::string &hostname, unsigned short port)
Create a new UDP log connection with the hostname (as name or IP) and the port to connect to.
Definition: LogConnectionUDP.cc:19
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LogConnectionUDP::m_socket
boost::asio::ip::udp::socket m_socket
the socket to the UDP server
Definition: LogConnectionUDP.h:45