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

Implementation of an IOChannel, using nidas::util::McSocket<nidas::util::Socket> to establish a TCP connection. More...

#include <McSocket.h>

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

Classes

class  MyMcSocket
 

Public Member Functions

 McSocket ()
 Constructor.
 
 ~McSocket ()
 
McSocketclone () const
 Derived classes must provide clone.
 
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)
 
IOChannelconnect ()
 
virtual void connected (nidas::util::Socket *sock, const nidas::util::Inet4PacketInfoX &pktinfo)
 
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 setKeepAliveIdleSecs (int val)
 
int getKeepAliveIdleSecs () const
 
void setNonBlocking (bool val)
 Do setNonBlocking(val) on underlying socket.
 
bool isNonBlocking () const
 Return isNonBlocking() of underlying socket.
 
size_t read (void *, size_t)
 A McSocket shouldn't be used to do any actual reads or writes, it just sets up the connection.
 
size_t write (const void *, size_t)
 A McSocket shouldn't be used to do any actual reads or writes, it just sets up the connection.
 
size_t write (const struct iovec *, int)
 A McSocket shouldn't be used to do any actual reads or writes, it just sets up the connection.
 
void close ()
 
int getFd () const
 
void fromDOMElement (const xercesc::DOMElement *)
 
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 size_t getBufferSize () const
 Return suggested buffer length.
 
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 Member Functions

 McSocket (const McSocket &)
 Copy constructor.
 

Protected Attributes

IOChannelRequester_iochanRequester
 
MyMcSocket _mcsocket
 

Private Member Functions

McSocketoperator= (const McSocket &)
 No assignment.
 

Private Attributes

std::string _name
 
bool _amRequester
 
bool _firstRead
 
bool _newInput
 
int _keepAliveIdleSecs
 
bool _nonBlocking
 
const DSMConfig_dsm
 
ConnectionInfo _conInfo
 

Static Private Attributes

static XMLChnamespaceURI = 0
 

Detailed Description

Implementation of an IOChannel, using nidas::util::McSocket<nidas::util::Socket> to establish a TCP connection.

Constructor & Destructor Documentation

◆ McSocket() [1/2]

McSocket::McSocket ( )

Constructor.

References setName().

Referenced by clone().

◆ ~McSocket()

nidas::core::McSocket::~McSocket ( )
inline

◆ McSocket() [2/2]

McSocket::McSocket ( const McSocket & x)
protected

Copy constructor.

Should only be called before nidas::util::Socket is connected.

Member Function Documentation

◆ 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()

McSocket * McSocket::clone ( ) const
virtual

Derived classes must provide clone.

Implements nidas::core::IOChannel.

References McSocket().

◆ close()

void McSocket::close ( )
virtual

◆ connect()

IOChannel * McSocket::connect ( )
virtual

◆ connected()

void McSocket::connected ( nidas::util::Socket * sock,
const nidas::util::Inet4PacketInfoX & pktinfo )
virtual

◆ 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 McSocket::fromDOMElement ( const xercesc::DOMElement * node)
virtual

◆ getBufferSize()

virtual size_t nidas::core::IOChannel::getBufferSize ( ) const
inlinevirtualinherited

◆ 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().

◆ 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 McSocket::getFd ( ) const
virtual

◆ getInet4McastSocketAddress()

const nidas::util::Inet4SocketAddress & nidas::core::McSocket::getInet4McastSocketAddress ( ) const
inline

◆ getKeepAliveIdleSecs()

int nidas::core::McSocket::getKeepAliveIdleSecs ( ) const
inline

◆ getName()

const std::string & nidas::core::McSocket::getName ( ) const
inlinevirtual

Implements nidas::core::IOChannel.

References _name.

Referenced by fromDOMElement().

◆ getNamespaceURI()

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

◆ getReconnectDelaySecs()

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

◆ getRequestType()

enum McSocketRequest nidas::core::McSocket::getRequestType ( ) const
inlinevirtual

◆ isNewInput()

virtual bool nidas::core::McSocket::isNewInput ( ) const
inlinevirtual

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 _newInput.

◆ isNonBlocking()

bool nidas::core::McSocket::isNonBlocking ( ) const
inlinevirtual

Return isNonBlocking() of underlying socket.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References _nonBlocking.

Referenced by connect(), and connected().

◆ isRequester()

bool nidas::core::McSocket::isRequester ( ) const
inline

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

References _amRequester.

Referenced by connect(), fromDOMElement(), and requestConnection().

◆ operator=()

McSocket & nidas::core::McSocket::operator= ( const McSocket & )
private

No assignment.

◆ read()

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

A McSocket 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.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References nidas::core::getSample().

◆ requestConnection()

void McSocket::requestConnection ( IOChannelRequester * service)
virtual

◆ setConnectionInfo()

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

◆ setDSMConfig()

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

◆ setInet4McastSocketAddress()

void nidas::core::McSocket::setInet4McastSocketAddress ( const nidas::util::Inet4SocketAddress & val)
inline

◆ setKeepAliveIdleSecs()

void nidas::core::McSocket::setKeepAliveIdleSecs ( int val)
inline

◆ setName()

void nidas::core::McSocket::setName ( const std::string & val)
inlinevirtual

Implements nidas::core::IOChannel.

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

Referenced by McSocket().

◆ setNonBlocking()

void nidas::core::McSocket::setNonBlocking ( bool val)
inlinevirtual

Do setNonBlocking(val) on underlying socket.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

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

Referenced by fromDOMElement().

◆ setRequester()

void nidas::core::McSocket::setRequester ( bool val)
inline

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

Referenced by fromDOMElement().

◆ setRequestType()

void nidas::core::McSocket::setRequestType ( enum McSocketRequest val)
inlinevirtual

◆ 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 nidas::core::McSocket::write ( const struct iovec * ,
int  )
inlinevirtual

A McSocket 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.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References nidas::core::getSample().

◆ write() [2/2]

size_t nidas::core::McSocket::write ( const void * ,
size_t  )
inlinevirtual

A McSocket 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.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References nidas::core::getSample().

◆ 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::McSocket::_amRequester
private

Referenced by isRequester(), and setRequester().

◆ _conInfo

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

◆ _dsm

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

◆ _firstRead

bool nidas::core::McSocket::_firstRead
private

◆ _iochanRequester

IOChannelRequester* nidas::core::McSocket::_iochanRequester
protected

Referenced by connected(), and requestConnection().

◆ _keepAliveIdleSecs

int nidas::core::McSocket::_keepAliveIdleSecs
private

◆ _mcsocket

MyMcSocket nidas::core::McSocket::_mcsocket
protected

◆ _name

std::string nidas::core::McSocket::_name
private

Referenced by getName(), and setName().

◆ _newInput

bool nidas::core::McSocket::_newInput
private

Referenced by isNewInput().

◆ _nonBlocking

bool nidas::core::McSocket::_nonBlocking
private

Referenced by isNonBlocking(), and setNonBlocking().

◆ namespaceURI

XMLCh * DOMable::namespaceURI = 0
staticprivateinherited

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