nidas v1.2.3
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::core::MultipleUDPSockets Class Reference

#include <MultipleUDPSockets.h>

Inheritance diagram for nidas::core::MultipleUDPSockets:
Inheritance graph
[legend]

Public Member Functions

 MultipleUDPSockets ()
 
 MultipleUDPSockets (const MultipleUDPSockets &x)
 
MultipleUDPSocketsclone () const
 Derived classes must provide clone.
 
IOChannelconnect ()
 
void connected (nidas::util::DatagramSocket *sock, const nidas::util::Inet4PacketInfoX &pktinfo) throw ()
 
size_t getBufferSize () const throw ()
 Return suggested buffer length.
 
size_t read (void *, size_t)
 
size_t write (const void *buf, size_t len)
 
size_t write (const struct iovec *iov, int iovcnt)
 
void close ()
 
int getFd () const
 
void fromDOMElement (const xercesc::DOMElement *)
 
void addClient (const ConnectionInfo &info)
 From the Inet4PacketInfoX associated with the received request, determine if we need to create a new socket to send data to the requester.
 
void removeClient (const nidas::util::Inet4SocketAddress &remoteSAddr)
 
void removeClient (nidas::util::DatagramSocket *)
 
void setDataPort (unsigned short val)
 
unsigned short getDataPort () const
 
void setRequestType (enum McSocketRequest val)
 
enum McSocketRequest getRequestType () const
 
bool isRequester () const
 Does this McSocket request connections, or does it listen for incoming connections.
 
void setRequester (bool val)
 
void setName (const std::string &val)
 
const std::string & getName () const
 
void requestConnection (IOChannelRequester *service)
 
virtual bool isNewInput () const
 Some IOChannels, namely FileSet, which opens successive files, need to indicate when a read is from the start of a new file.
 
void setNonBlocking (bool val)
 Do setNonBlocking(val) on underlying socket.
 
bool isNonBlocking () const
 Return isNonBlocking() of underlying socket.
 
void setInet4McastSocketAddress (const nidas::util::Inet4SocketAddress &val)
 
const nidas::util::Inet4SocketAddressgetInet4McastSocketAddress () const
 
virtual int getReconnectDelaySecs () const
 
virtual const ConnectionInfogetConnectionInfo () const
 What is the IP address of the host at the other end of the connection.
 
virtual void setConnectionInfo (const ConnectionInfo &val)
 
virtual void flush ()
 Default flush implementation does nothing.
 
virtual dsm_time_t createFile (dsm_time_t t, bool exact)
 Request that an IOChannel open a new file, with a name based on a time.
 
virtual bool writeNidasHeader () const
 Should the NIDAS header be written to this IOChannel? NIDAS headers are not written to DatagramSockets, because there is no guarantee they will get there.
 
virtual void setDSMConfig (const DSMConfig *val)
 What DSM is this IOChannel connected to?
 
virtual const DSMConfiggetDSMConfig () const
 What DSM is this IOChannel connected to? May be NULL.
 
virtual void addSampleTag (const nidas::core::SampleTag *)
 The special NetcdfRPCChannel subclass needs a way to add a SampleTag to the IOChannel through a virtual base class.
 
virtual xercesc::DOMElement * toDOMParent (xercesc::DOMElement *parent, bool complete) const
 Create a DOMElement and append it to the parent.
 
virtual xercesc::DOMElement * toDOMElement (xercesc::DOMElement *node, bool complete) const
 Add my content into a DOMElement.
 

Static Public Member Functions

static IOChannelcreateIOChannel (const xercesc::DOMElement *node)
 
static const XMLChgetNamespaceURI ()
 

Protected Attributes

IOChannelRequester_iochanRequester
 
MyMcSocket _mcsocket
 

Private Member Functions

void handleChangedSockets ()
 

Private Attributes

nidas::util::Mutex _socketMutex
 
std::list< std::pair< nidas::util::DatagramSocket *, nidas::util::Inet4SocketAddress > > _sockets
 
std::list< std::pair< nidas::util::DatagramSocket *, nidas::util::Inet4SocketAddress > > _pendingSockets
 
std::list< nidas::util::DatagramSocket * > _pendingRemoveSockets
 
std::map< nidas::util::Inet4SocketAddress, nidas::util::Inet4Address_multicastInterfaces
 The local multicast interface of each remote client.
 
std::map< nidas::util::Inet4Address, std::set< nidas::util::Inet4SocketAddress > > _multicastClients
 Remote clients of each multicast interface.
 
std::map< nidas::util::Inet4Address, nidas::util::DatagramSocket * > _multicastSockets
 Socket of each multicast interface.
 
std::map< nidas::util::Inet4SocketAddress, nidas::util::DatagramSocket * > _unicastSockets
 Unicast Sockets for each destination.
 
bool _socketsChanged
 
unsigned short _dataPortNumber
 
std::string _name
 
bool _amRequester
 
bool _firstRead
 
bool _newInput
 
bool _nonBlocking
 
const DSMConfig_dsm
 
ConnectionInfo _conInfo
 

Static Private Attributes

static XMLChnamespaceURI = 0
 

Constructor & Destructor Documentation

◆ MultipleUDPSockets() [1/2]

MultipleUDPSockets::MultipleUDPSockets ( )

References nidas::core::McSocketUDP::setName().

Referenced by clone().

◆ MultipleUDPSockets() [2/2]

MultipleUDPSockets::MultipleUDPSockets ( const MultipleUDPSockets & x)

Member Function Documentation

◆ addClient()

void MultipleUDPSockets::addClient ( const ConnectionInfo & info)

From the Inet4PacketInfoX associated with the received request, determine if we need to create a new socket to send data to the requester.

If this is a new destination address for unicast packets add a new nidas::util::DatagramSocket. Or, if the requester sent a multicast request, and it was received on an interface which has not received requests before, then add a new nidas::util::MulticastSocket on that interface.

References _multicastClients, _multicastInterfaces, _multicastSockets, _pendingSockets, _socketMutex, _socketsChanged, _unicastSockets, getDataPort(), nidas::core::ConnectionInfo::getDestinationAddress(), nidas::core::McSocketUDP::getInet4McastSocketAddress(), nidas::core::ConnectionInfo::getInterface(), nidas::core::ConnectionInfo::getRemoteSocketAddress(), nidas::core::getSample(), ILOG, nidas::util::Mutex::lock(), and nidas::util::Mutex::unlock().

Referenced by connect().

◆ addSampleTag()

void IOChannel::addSampleTag ( const nidas::core::SampleTag * )
virtualinherited

The special NetcdfRPCChannel subclass needs a way to add a SampleTag to the IOChannel through a virtual base class.

This method does nothing and serves no purpose except for that class.

◆ clone()

MultipleUDPSockets * MultipleUDPSockets::clone ( ) const
virtual

Derived classes must provide clone.

Reimplemented from nidas::core::McSocketUDP.

References MultipleUDPSockets().

◆ close()

void MultipleUDPSockets::close ( )
virtual

◆ connect()

IOChannel * MultipleUDPSockets::connect ( )
virtual

◆ connected()

void MultipleUDPSockets::connected ( nidas::util::DatagramSocket * sock,
const nidas::util::Inet4PacketInfoX & pktinfo )
throw ( )
virtual

Reimplemented from nidas::core::McSocketUDP.

References nidas::core::getSample(), and ILOG.

◆ createFile()

virtual dsm_time_t nidas::core::IOChannel::createFile ( dsm_time_t t,
bool exact )
inlinevirtualinherited

Request that an IOChannel open a new file, with a name based on a time.

This should be implemented by derived classes which write to disk files. Other derived classes (e.g. sockets) can just use this default implementation - basically ignoring the request.

Parameters
tTime to use when creating file name.
exactUse exact time when creating file name, else the time is adjusted to an even time interval.
Exceptions
nidas::util::IOException

Reimplemented in nidas::core::FileSet.

References nidas::core::getSample().

Referenced by nidas::core::IOStream::createFile(), and nidas::core::SampleOutputBase::createNextFile().

◆ createIOChannel()

IOChannel * IOChannel::createIOChannel ( const xercesc::DOMElement * node)
staticinherited

◆ flush()

virtual void nidas::core::IOChannel::flush ( )
inlinevirtualinherited

Default flush implementation does nothing.

Exceptions
nidas::util::IOException

Referenced by nidas::core::IOStream::flush().

◆ fromDOMElement()

void MultipleUDPSockets::fromDOMElement ( const xercesc::DOMElement * node)
virtual

◆ getBufferSize()

size_t MultipleUDPSockets::getBufferSize ( ) const
throw ( )
virtual

◆ getConnectionInfo()

virtual const ConnectionInfo & nidas::core::IOChannel::getConnectionInfo ( ) const
inlinevirtualinherited

What is the IP address of the host at the other end of the connection.

If this IOChannel is not a socket then return INADDR_ANY, using the default constructor of an Inet4Address. Socket subclasses should override this.

References nidas::core::IOChannel::_conInfo.

Referenced by nidas::dynld::SampleInputStream::setIOChannel().

◆ getDataPort()

unsigned short nidas::core::MultipleUDPSockets::getDataPort ( ) const
inline

References _dataPortNumber, and nidas::core::getSample().

Referenced by addClient().

◆ getDSMConfig()

virtual const DSMConfig * nidas::core::IOChannel::getDSMConfig ( ) const
inlinevirtualinherited

What DSM is this IOChannel connected to? May be NULL.

References nidas::core::IOChannel::_dsm.

Referenced by nidas::core::FileSet::setDir(), and nidas::core::FileSet::setFileName().

◆ getFd()

int MultipleUDPSockets::getFd ( ) const
virtual

◆ getInet4McastSocketAddress()

const nidas::util::Inet4SocketAddress & nidas::core::McSocketUDP::getInet4McastSocketAddress ( ) const
inlineinherited

◆ getName()

const std::string & nidas::core::McSocketUDP::getName ( ) const
inlinevirtualinherited

◆ getNamespaceURI()

static const XMLCh * nidas::core::DOMable::getNamespaceURI ( )
inlinestaticinherited

◆ getReconnectDelaySecs()

virtual int nidas::core::IOChannel::getReconnectDelaySecs ( ) const
inlinevirtualinherited

◆ getRequestType()

enum McSocketRequest nidas::core::McSocketUDP::getRequestType ( ) const
inlinevirtualinherited

◆ handleChangedSockets()

void MultipleUDPSockets::handleChangedSockets ( )
private

◆ isNewInput()

virtual bool nidas::core::McSocketUDP::isNewInput ( ) const
inlinevirtualinherited

Some IOChannels, namely FileSet, which opens successive files, need to indicate when a read is from the start of a new file.

This method is used by code which may need to do special things at the beginning of a file, like read a SampleInputHeader.

Reimplemented from nidas::core::IOChannel.

References nidas::core::McSocketUDP::_newInput.

◆ isNonBlocking()

bool nidas::core::McSocketUDP::isNonBlocking ( ) const
inlinevirtualinherited

◆ isRequester()

bool nidas::core::McSocketUDP::isRequester ( ) const
inlineinherited

Does this McSocket request connections, or does it listen for incoming connections.

References nidas::core::McSocketUDP::_amRequester.

Referenced by nidas::core::McSocketUDP::connect(), nidas::core::McSocketUDP::fromDOMElement(), and nidas::core::McSocketUDP::requestConnection().

◆ read()

size_t nidas::core::MultipleUDPSockets::read ( void * ,
size_t  )
inlinevirtual

◆ removeClient() [1/2]

void MultipleUDPSockets::removeClient ( const nidas::util::Inet4SocketAddress & remoteSAddr)

◆ removeClient() [2/2]

void MultipleUDPSockets::removeClient ( nidas::util::DatagramSocket * dsock)

◆ requestConnection()

void McSocketUDP::requestConnection ( IOChannelRequester * service)
virtualinherited

◆ setConnectionInfo()

virtual void nidas::core::IOChannel::setConnectionInfo ( const ConnectionInfo & val)
inlinevirtualinherited

◆ setDataPort()

void nidas::core::MultipleUDPSockets::setDataPort ( unsigned short val)
inline

◆ setDSMConfig()

virtual void nidas::core::IOChannel::setDSMConfig ( const DSMConfig * val)
inlinevirtualinherited

◆ setInet4McastSocketAddress()

void nidas::core::McSocketUDP::setInet4McastSocketAddress ( const nidas::util::Inet4SocketAddress & val)
inlineinherited

◆ setName()

void nidas::core::McSocketUDP::setName ( const std::string & val)
inlinevirtualinherited

◆ setNonBlocking()

void nidas::core::McSocketUDP::setNonBlocking ( bool val)
inlinevirtualinherited

◆ setRequester()

void nidas::core::McSocketUDP::setRequester ( bool val)
inlineinherited

◆ setRequestType()

void nidas::core::McSocketUDP::setRequestType ( enum McSocketRequest val)
inlinevirtualinherited

◆ toDOMElement()

xercesc::DOMElement * DOMable::toDOMElement ( xercesc::DOMElement * node,
bool complete ) const
virtualinherited

◆ toDOMParent()

xercesc::DOMElement * DOMable::toDOMParent ( xercesc::DOMElement * parent,
bool complete ) const
virtualinherited

Create a DOMElement and append it to the parent.

Exceptions
xercesc::DOMException

Reimplemented in nidas::core::DSMConfig, nidas::core::DSMSensor, nidas::core::Project, nidas::core::SampleTag, nidas::core::Site, nidas::core::ServerSocket, and nidas::core::Variable.

◆ write() [1/2]

size_t MultipleUDPSockets::write ( const struct iovec * iov,
int iovcnt )
virtual

◆ write() [2/2]

size_t MultipleUDPSockets::write ( const void * buf,
size_t len )
virtual

◆ writeNidasHeader()

virtual bool nidas::core::IOChannel::writeNidasHeader ( ) const
inlinevirtualinherited

Should the NIDAS header be written to this IOChannel? NIDAS headers are not written to DatagramSockets, because there is no guarantee they will get there.

Reimplemented in nidas::core::DatagramSocket.

Referenced by nidas::dynld::SampleInputStream::setIOChannel().

Member Data Documentation

◆ _amRequester

bool nidas::core::McSocketUDP::_amRequester
privateinherited

◆ _conInfo

ConnectionInfo nidas::core::IOChannel::_conInfo
privateinherited

◆ _dataPortNumber

unsigned short nidas::core::MultipleUDPSockets::_dataPortNumber
private

Referenced by getDataPort(), and setDataPort().

◆ _dsm

const DSMConfig* nidas::core::IOChannel::_dsm
privateinherited

◆ _firstRead

bool nidas::core::McSocketUDP::_firstRead
privateinherited

◆ _iochanRequester

IOChannelRequester* nidas::core::McSocketUDP::_iochanRequester
protectedinherited

◆ _mcsocket

MyMcSocket nidas::core::McSocketUDP::_mcsocket
protectedinherited

◆ _multicastClients

std::map<nidas::util::Inet4Address,std::set<nidas::util::Inet4SocketAddress> > nidas::core::MultipleUDPSockets::_multicastClients
private

Remote clients of each multicast interface.

Referenced by addClient(), removeClient(), and removeClient().

◆ _multicastInterfaces

std::map<nidas::util::Inet4SocketAddress,nidas::util::Inet4Address> nidas::core::MultipleUDPSockets::_multicastInterfaces
private

The local multicast interface of each remote client.

Referenced by addClient(), removeClient(), and removeClient().

◆ _multicastSockets

std::map<nidas::util::Inet4Address,nidas::util::DatagramSocket*> nidas::core::MultipleUDPSockets::_multicastSockets
private

Socket of each multicast interface.

Referenced by addClient(), removeClient(), and removeClient().

◆ _name

std::string nidas::core::McSocketUDP::_name
privateinherited

◆ _newInput

bool nidas::core::McSocketUDP::_newInput
privateinherited

◆ _nonBlocking

bool nidas::core::McSocketUDP::_nonBlocking
privateinherited

◆ _pendingRemoveSockets

std::list<nidas::util::DatagramSocket*> nidas::core::MultipleUDPSockets::_pendingRemoveSockets
private

◆ _pendingSockets

std::list<std::pair<nidas::util::DatagramSocket*,nidas::util::Inet4SocketAddress> > nidas::core::MultipleUDPSockets::_pendingSockets
private

◆ _socketMutex

nidas::util::Mutex nidas::core::MultipleUDPSockets::_socketMutex
mutableprivate

◆ _sockets

std::list<std::pair<nidas::util::DatagramSocket*,nidas::util::Inet4SocketAddress> > nidas::core::MultipleUDPSockets::_sockets
private

◆ _socketsChanged

bool nidas::core::MultipleUDPSockets::_socketsChanged
private

◆ _unicastSockets

std::map<nidas::util::Inet4SocketAddress,nidas::util::DatagramSocket*> nidas::core::MultipleUDPSockets::_unicastSockets
private

Unicast Sockets for each destination.

Referenced by addClient(), removeClient(), and removeClient().

◆ namespaceURI

XMLCh * DOMable::namespaceURI = 0
staticprivateinherited

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