-
Jorrit Schaap authoredJorrit Schaap authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
EventPort.cc 12.49 KiB
//# EventPort.cc: (raw) socket based implementation to exchange Events
//#
//# Copyright (C) 2007
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, softwaresupport@astron.nl
//#
//# This program is free software; you can redistribute it and/or modify
//# it under the terms of the GNU General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or
//# (at your option) any later version.
//#
//# This program is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License
//# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# $Id$
//# Always #include <lofar_config.h> first!
#include <lofar_config.h>
//# Includes
#include <Common/LofarLogger.h>
#include <Common/StringUtil.h>
#include <Common/SystemUtil.h>
#include <Common/hexdump.h>
#include <MACIO/MACServiceInfo.h>
#include <MACIO/GCF_Event.h>
#include <MACIO/EventPort.h>
#include <SB_Protocol.ph>
//#include "GSB_Defines.h"
namespace LOFAR {
using namespace SB_Protocol;
namespace MACIO {
// Note: the difference with GCF-ports is that this port is only based on the
// LCS/Common sockets and does therefor not depend on GCF_Tasks.
//
// EventPort (name, type, protocol)
//
EventPort::EventPort(const string& aServiceMask,
bool aServerSocket,
int aProtocol,
const string& aHostname,
bool syncCommunication) :
itsPort (0),
itsHost (aHostname),
itsServiceName (_makeServiceName(aServiceMask, 0)),
itsSocket (0),
itsListenSocket (0),
itsBrokerSocket (0),
itsStatus (EP_CREATED),
itsSyncComm (syncCommunication),
itsIsServer (aServerSocket),
itsBtsToRead (0),
itsTotalBtsRead (0),
itsReadState (0),
itsEventHdr (0),
itsEventBuf (0)
{
(void)aProtocol; // avoid compiler warning
if (itsHost.empty() || itsHost == "localhost") {
itsHost = myHostname(false);