nidas  v1.2-1520
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | 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. More...
 
IOChannelconnect () throw (nidas::util::IOException)
 Establish a connection. More...
 
void connected (nidas::util::DatagramSocket *sock, const nidas::util::Inet4PacketInfoX &pktinfo) throw ()
 
size_t getBufferSize () const throw ()
 Return suggested buffer length. More...
 
size_t read (void *, size_t) throw (nidas::util::IOException)
 A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection. More...
 
size_t write (const void *buf, size_t len) throw (nidas::util::IOException)
 A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection. More...
 
size_t write (const struct iovec *iov, int iovcnt) throw (nidas::util::IOException)
 A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection. More...
 
void close () throw (nidas::util::IOException)
 
int getFd () const
 
void fromDOMElement (const xercesc::DOMElement *) throw (nidas::util::InvalidParameterException)
 Initialize myself from a xercesc::DOMElement. More...
 
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. More...
 
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. More...
 
void setRequester (bool val)
 
void setName (const std::string &val)
 
const std::string & getName () const
 
void requestConnection (IOChannelRequester *service) throw (nidas::util::IOException)
 After the IOChannel is configured, a user of IOChannel calls requestConnection to get things started. More...
 
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. More...
 
void setNonBlocking (bool val) throw (nidas::util::IOException)
 Do setNonBlocking(val) on underlying socket. More...
 
bool isNonBlocking () const throw (nidas::util::IOException)
 Return isNonBlocking() of underlying socket. More...
 
void setInet4McastSocketAddress (const nidas::util::Inet4SocketAddress &val)
 
const
nidas::util::Inet4SocketAddress
getInet4McastSocketAddress () const
 
virtual int getReconnectDelaySecs () const
 
virtual const ConnectionInfogetConnectionInfo () const
 What is the IP address of the host at the other end of the connection. More...
 
virtual void setConnectionInfo (const ConnectionInfo &val)
 
virtual void flush () throw (nidas::util::IOException)
 Default flush implementation does nothing. More...
 
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. More...
 
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. More...
 
virtual void setDSMConfig (const DSMConfig *val)
 What DSM is this IOChannel connected to? More...
 
virtual const DSMConfiggetDSMConfig () const
 What DSM is this IOChannel connected to? May be NULL. More...
 
virtual xercesc::DOMElement * toDOMParent (xercesc::DOMElement *parent, bool complete) const throw (xercesc::DOMException)
 Create a DOMElement and append it to the parent. More...
 
virtual xercesc::DOMElement * toDOMElement (xercesc::DOMElement *node, bool complete) const throw (xercesc::DOMException)
 Add my content into a DOMElement. More...
 

Static Public Member Functions

static IOChannelcreateIOChannel (const xercesc::DOMElement *node) throw (nidas::util::InvalidParameterException)
 
static const XMLCh * getNamespaceURI ()
 

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. More...
 
std::map
< nidas::util::Inet4Address,
std::set
< nidas::util::Inet4SocketAddress > > 
_multicastClients
 Remote clients of each multicast interface. More...
 
std::map
< nidas::util::Inet4Address,
nidas::util::DatagramSocket * > 
_multicastSockets
 Socket of each multicast interface. More...
 
std::map
< nidas::util::Inet4SocketAddress,
nidas::util::DatagramSocket * > 
_unicastSockets
 Unicast Sockets for each destination. More...
 
bool _socketsChanged
 
unsigned short _dataPortNumber
 

Constructor & Destructor Documentation

MultipleUDPSockets::MultipleUDPSockets ( )

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

Referenced by clone().

MultipleUDPSockets::MultipleUDPSockets ( const MultipleUDPSockets x)

Member Function Documentation

void MultipleUDPSockets::addClient ( const ConnectionInfo info)
MultipleUDPSockets * MultipleUDPSockets::clone ( ) const
virtual

Derived classes must provide clone.

Reimplemented from nidas::core::McSocketUDP.

References MultipleUDPSockets().

void MultipleUDPSockets::close ( )
throw (nidas::util::IOException
)
virtual
IOChannel * MultipleUDPSockets::connect ( )
throw (nidas::util::IOException
)
virtual
void MultipleUDPSockets::connected ( nidas::util::DatagramSocket sock,
const nidas::util::Inet4PacketInfoX pktinfo 
)
throw (
)
virtual

Reimplemented from nidas::core::McSocketUDP.

References ILOG.

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.

Reimplemented in nidas::core::FileSet.

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

IOChannel * IOChannel::createIOChannel ( const xercesc::DOMElement *  node)
throw (nidas::util::InvalidParameterException
)
staticinherited
virtual void nidas::core::IOChannel::flush ( )
throw (nidas::util::IOException
)
inlinevirtualinherited
void MultipleUDPSockets::fromDOMElement ( const xercesc::DOMElement *  )
throw (nidas::util::InvalidParameterException
)
virtual
size_t MultipleUDPSockets::getBufferSize ( ) const
throw (
)
virtual

Return suggested buffer length.

Reimplemented from nidas::core::IOChannel.

References _socketMutex, _sockets, and nidas::util::DatagramSocket::getReceiveBufferSize().

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.

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

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

References _dataPortNumber.

Referenced by addClient().

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

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

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

int MultipleUDPSockets::getFd ( ) const
virtual
const nidas::util::Inet4SocketAddress& nidas::core::McSocketUDP::getInet4McastSocketAddress ( ) const
inlineinherited
const std::string& nidas::core::McSocketUDP::getName ( ) const
inlinevirtualinherited
static const XMLCh* nidas::core::DOMable::getNamespaceURI ( )
inlinestaticinherited
virtual int nidas::core::IOChannel::getReconnectDelaySecs ( ) const
inlinevirtualinherited
enum McSocketRequest nidas::core::McSocketUDP::getRequestType ( ) const
inlinevirtualinherited
void MultipleUDPSockets::handleChangedSockets ( )
private
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.

bool nidas::core::McSocketUDP::isNonBlocking ( ) const
throw (nidas::util::IOException
)
inlinevirtualinherited
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().

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

A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.

The returned IOChannel should be used to read/write. Calling this method will fail with an assert.

Reimplemented from nidas::core::McSocketUDP.

void MultipleUDPSockets::removeClient ( const nidas::util::Inet4SocketAddress remoteSAddr)
void MultipleUDPSockets::removeClient ( nidas::util::DatagramSocket dsock)
void McSocketUDP::requestConnection ( IOChannelRequester )
throw (nidas::util::IOException
)
virtualinherited

After the IOChannel is configured, a user of IOChannel calls requestConnection to get things started.

It is like opening a device, but in the case of server sockets, it just starts a thread to wait on connections. Only when the IOChannelRequester::connected() method is called back is the channel actually open and ready for IO. The IOChannel* returned by IOChannelRequester::connected may be another instance of an IOChannel.

Implements nidas::core::IOChannel.

virtual void nidas::core::IOChannel::setConnectionInfo ( const ConnectionInfo val)
inlinevirtualinherited
void nidas::core::MultipleUDPSockets::setDataPort ( unsigned short  val)
inline

References _dataPortNumber.

virtual void nidas::core::IOChannel::setDSMConfig ( const DSMConfig val)
inlinevirtualinherited
void nidas::core::McSocketUDP::setInet4McastSocketAddress ( const nidas::util::Inet4SocketAddress val)
inlineinherited
void nidas::core::McSocketUDP::setName ( const std::string &  val)
inlinevirtualinherited
void nidas::core::McSocketUDP::setNonBlocking ( bool  val)
throw (nidas::util::IOException
)
inlinevirtualinherited

Do setNonBlocking(val) on underlying socket.

Implements nidas::core::IOChannel.

References nidas::core::McSocketUDP::_nonBlocking.

void nidas::core::McSocketUDP::setRequester ( bool  val)
inlineinherited
void nidas::core::McSocketUDP::setRequestType ( enum McSocketRequest  val)
inlinevirtualinherited
xercesc::DOMElement * DOMable::toDOMElement ( xercesc::DOMElement *  node,
bool  complete 
) const
throw (xercesc::DOMException
)
virtualinherited
xercesc::DOMElement * DOMable::toDOMParent ( xercesc::DOMElement *  parent,
bool  complete 
) const
throw (xercesc::DOMException
)
virtualinherited
size_t MultipleUDPSockets::write ( const void *  ,
size_t   
)
throw (nidas::util::IOException
)
virtual

A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.

The returned IOChannel should be used to read/write. Calling this method will fail with an assert.

Reimplemented from nidas::core::McSocketUDP.

References ILOG, len, nidas::util::DatagramSocket::sendto(), and nidas::util::Exception::what().

size_t MultipleUDPSockets::write ( const struct iovec *  ,
int   
)
throw (nidas::util::IOException
)
virtual

A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.

The returned IOChannel should be used to read/write. Calling this method will fail with an assert.

Reimplemented from nidas::core::McSocketUDP.

References ILOG, nidas::util::DatagramSocket::sendto(), and nidas::util::Exception::what().

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

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

Referenced by getDataPort(), and setDataPort().

IOChannelRequester* nidas::core::McSocketUDP::_iochanRequester
protectedinherited
MyMcSocket nidas::core::McSocketUDP::_mcsocket
protectedinherited
std::map<nidas::util::Inet4Address,std::set<nidas::util::Inet4SocketAddress> > nidas::core::MultipleUDPSockets::_multicastClients
private

Remote clients of each multicast interface.

Referenced by addClient(), and removeClient().

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

The local multicast interface of each remote client.

Referenced by addClient(), and removeClient().

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

Socket of each multicast interface.

Referenced by addClient(), and removeClient().

std::list<nidas::util::DatagramSocket*> nidas::core::MultipleUDPSockets::_pendingRemoveSockets
private
std::list<std::pair<nidas::util::DatagramSocket*,nidas::util::Inet4SocketAddress> > nidas::core::MultipleUDPSockets::_pendingSockets
private
nidas::util::Mutex nidas::core::MultipleUDPSockets::_socketMutex
mutableprivate
std::list<std::pair<nidas::util::DatagramSocket*,nidas::util::Inet4SocketAddress> > nidas::core::MultipleUDPSockets::_sockets
private
bool nidas::core::MultipleUDPSockets::_socketsChanged
private
std::map<nidas::util::Inet4SocketAddress,nidas::util::DatagramSocket*> nidas::core::MultipleUDPSockets::_unicastSockets
private

Unicast Sockets for each destination.

Referenced by addClient(), and removeClient().


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