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

Implementation of an IOChannel, over a ServerSocket. More...

#include <Socket.h>

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

Classes

class  ConnectionThread
 

Public Member Functions

 ServerSocket ()
 Constructor.
 
 ServerSocket (const nidas::util::SocketAddress &addr)
 Constructor.
 
 ~ServerSocket ()
 
ServerSocketclone () const
 Derived classes must provide clone.
 
void requestConnection (IOChannelRequester *service)
 
IOChannelconnect ()
 
const std::string & getName () const
 
void setName (const std::string &val)
 
int getFd () const
 
void setKeepAliveIdleSecs (int val)
 Set the value of keepAliveIdleSecs.
 
int getKeepAliveIdleSecs () const
 Return keepAliveIdleSecs for this ServerSocket.
 
void setNonBlocking (bool val)
 The blocking flag that will be set on accepted connections.
 
bool isNonBlocking () const
 
size_t read (void *, size_t)
 ServerSocket will never be called to do an actual read.
 
size_t write (const void *, size_t)
 ServerSocket should never be called to do an actual write.
 
size_t write (const struct iovec *, int)
 ServerSocket should never be called to do an actual write.
 
void close ()
 
void fromDOMElement (const xercesc::DOMElement *)
 
xercesc::DOMElement * toDOMParent (xercesc::DOMElement *parent, bool complete) const
 
xercesc::DOMElement * toDOMElement (xercesc::DOMElement *node, bool complete) const
 
virtual void setRequestType (enum McSocketRequest)
 
virtual enum McSocketRequest getRequestType () const
 
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.
 
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.
 

Static Public Member Functions

static IOChannelcreateSocket (const xercesc::DOMElement *)
 Create either a Socket or a McSocket from a DOMElement.
 
static IOChannelcreateIOChannel (const xercesc::DOMElement *node)
 
static const XMLChgetNamespaceURI ()
 

Protected Member Functions

 ServerSocket (const ServerSocket &x)
 Copy constructor.
 

Private Member Functions

ServerSocketoperator= (const ServerSocket &)
 No assignment.
 

Private Attributes

nidas::util::auto_ptr< nidas::util::SocketAddress_localSockAddr
 
std::string _name
 
nidas::util::ServerSocket_servSock
 
IOChannelRequester_iochanRequester
 
ConnectionThread_connectionThread
 
int _keepAliveIdleSecs
 
bool _nonBlocking
 
const DSMConfig_dsm
 
ConnectionInfo _conInfo
 

Static Private Attributes

static XMLChnamespaceURI = 0
 

Detailed Description

Implementation of an IOChannel, over a ServerSocket.

Constructor & Destructor Documentation

◆ ServerSocket() [1/3]

ServerSocket::ServerSocket ( )

Constructor.

References _localSockAddr, and setName().

Referenced by clone().

◆ ServerSocket() [2/3]

ServerSocket::ServerSocket ( const nidas::util::SocketAddress & addr)

Constructor.

References _localSockAddr, and setName().

◆ ~ServerSocket()

ServerSocket::~ServerSocket ( )

◆ ServerSocket() [3/3]

ServerSocket::ServerSocket ( const ServerSocket & x)
protected

Copy constructor.

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

ServerSocket * ServerSocket::clone ( ) const
virtual

Derived classes must provide clone.

Implements nidas::core::IOChannel.

References ServerSocket().

◆ close()

void ServerSocket::close ( )
virtual

◆ connect()

IOChannel * ServerSocket::connect ( )
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

◆ createSocket()

static IOChannel * nidas::core::ServerSocket::createSocket ( const xercesc::DOMElement * )
static

Create either a Socket or a McSocket from a DOMElement.

Exceptions
nidas::util::InvalidParameterException

◆ 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 ServerSocket::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 nidas::core::ServerSocket::getFd ( ) const
inlinevirtual

◆ getKeepAliveIdleSecs()

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

Return keepAliveIdleSecs for this ServerSocket.

Exceptions
nidas::util::IOException

References _keepAliveIdleSecs.

◆ getName()

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

Implements nidas::core::IOChannel.

References _name.

Referenced by requestConnection().

◆ getNamespaceURI()

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

◆ getReconnectDelaySecs()

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

◆ getRequestType()

virtual enum McSocketRequest nidas::core::IOChannel::getRequestType ( ) const
inlinevirtualinherited

◆ isNewInput()

virtual bool nidas::core::IOChannel::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 in nidas::core::DatagramSocket, nidas::core::FileSet, nidas::core::McSocket, nidas::core::McSocketUDP, nidas::core::Socket, and nidas::core::UnixIOChannel.

Referenced by nidas::core::IOStream::read(), nidas::core::IOStream::read(), and nidas::core::IOStream::readUntil().

◆ isNonBlocking()

bool nidas::core::ServerSocket::isNonBlocking ( ) const
inlinevirtual
Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References _nonBlocking.

◆ operator=()

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

No assignment.

◆ read()

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

ServerSocket will never be called to do an actual read.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References nidas::core::getSample().

◆ requestConnection()

void ServerSocket::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

◆ setKeepAliveIdleSecs()

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

Set the value of keepAliveIdleSecs.

This is set on each accepted socket connection. It does not pertain to the socket which is waiting for connections.

Exceptions
nidas::util::IOException

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

◆ setName()

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

Implements nidas::core::IOChannel.

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

Referenced by ServerSocket(), and ServerSocket().

◆ setNonBlocking()

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

The blocking flag that will be set on accepted connections.

The ServerSocket itself is always non-blocking.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

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

◆ setRequestType()

virtual void nidas::core::IOChannel::setRequestType ( enum McSocketRequest )
inlinevirtualinherited

◆ toDOMElement()

xercesc::DOMElement * ServerSocket::toDOMElement ( xercesc::DOMElement * node,
bool complete ) const
virtual
Exceptions
xercesc::DOMException

Reimplemented from nidas::core::DOMable.

References nidas::core::getSample().

◆ toDOMParent()

xercesc::DOMElement * ServerSocket::toDOMParent ( xercesc::DOMElement * parent,
bool complete ) const
virtual
Exceptions
xercesc::DOMException

Reimplemented from nidas::core::DOMable.

References nidas::core::DOMable::getNamespaceURI(), and nidas::core::DOMable::toDOMElement().

◆ write() [1/2]

size_t nidas::core::ServerSocket::write ( const struct iovec * ,
int  )
inlinevirtual

ServerSocket should never be called to do an actual write.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References nidas::core::getSample().

◆ write() [2/2]

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

ServerSocket should never be called to do an actual write.

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

◆ _conInfo

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

◆ _connectionThread

ConnectionThread* nidas::core::ServerSocket::_connectionThread
private

◆ _dsm

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

◆ _iochanRequester

IOChannelRequester* nidas::core::ServerSocket::_iochanRequester
private

Referenced by requestConnection().

◆ _keepAliveIdleSecs

int nidas::core::ServerSocket::_keepAliveIdleSecs
private

◆ _localSockAddr

nidas::util::auto_ptr<nidas::util::SocketAddress> nidas::core::ServerSocket::_localSockAddr
private

◆ _name

std::string nidas::core::ServerSocket::_name
private

Referenced by getName(), and setName().

◆ _nonBlocking

bool nidas::core::ServerSocket::_nonBlocking
private

◆ _servSock

nidas::util::ServerSocket* nidas::core::ServerSocket::_servSock
private

◆ namespaceURI

XMLCh * DOMable::namespaceURI = 0
staticprivateinherited

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