nidas v1.2.3
|
Implementation of an IOChannel, using nidas::util::McSocket<nidas::util::DatagramSocket> to establish a pair of communicating UDP sockets. More...
#include <McSocketUDP.h>
Classes | |
class | MyMcSocket |
Public Member Functions | |
McSocketUDP () | |
Constructor. | |
McSocketUDP (const McSocketUDP &) | |
Copy constructor. | |
~McSocketUDP () | |
McSocketUDP * | clone () 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) |
IOChannel * | connect () |
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 void | connected (nidas::util::DatagramSocket *sock, const nidas::util::Inet4PacketInfoX &pktinfo) |
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 McSocketUDP 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 McSocketUDP 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 McSocketUDP 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::Inet4SocketAddress & | getInet4McastSocketAddress () const |
virtual int | getReconnectDelaySecs () const |
virtual const ConnectionInfo & | getConnectionInfo () 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 DSMConfig * | getDSMConfig () 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 IOChannel * | createIOChannel (const xercesc::DOMElement *node) |
static const XMLCh * | getNamespaceURI () |
Protected Attributes | |
IOChannelRequester * | _iochanRequester |
MyMcSocket | _mcsocket |
Private Member Functions | |
McSocketUDP & | operator= (const McSocketUDP &) |
No assignment. | |
Private Attributes | |
std::string | _name |
bool | _amRequester |
bool | _firstRead |
bool | _newInput |
bool | _nonBlocking |
const DSMConfig * | _dsm |
ConnectionInfo | _conInfo |
Static Private Attributes | |
static XMLCh * | namespaceURI = 0 |
Implementation of an IOChannel, using nidas::util::McSocket<nidas::util::DatagramSocket> to establish a pair of communicating UDP sockets.
Implementation of an IOChannel, using McSocket to establish connections
McSocketUDP::McSocketUDP | ( | const McSocketUDP & | x | ) |
Copy constructor.
Should only be called before nidas::util::Socket is connected.
|
inline |
|
virtualinherited |
|
virtual |
Derived classes must provide clone.
Implements nidas::core::IOChannel.
Reimplemented in nidas::core::MultipleUDPSockets.
References McSocketUDP().
|
virtual |
nidas::util::IOException |
Implements nidas::core::IOChannel.
Reimplemented in nidas::core::MultipleUDPSockets.
References _mcsocket, and nidas::util::McSocket< SocketT >::close().
|
virtual |
nidas::util::IOException |
Implements nidas::core::IOChannel.
Reimplemented in nidas::core::MultipleUDPSockets.
References _mcsocket, nidas::util::McSocket< SocketT >::accept(), nidas::util::McSocket< SocketT >::connect(), nidas::core::getSample(), isNonBlocking(), isRequester(), and nidas::util::DatagramSocket::setNonBlocking().
|
virtual |
Reimplemented in nidas::core::MultipleUDPSockets.
References _iochanRequester, nidas::core::IOChannelRequester::connected(), nidas::core::getSample(), and isNonBlocking().
Referenced by nidas::core::McSocketUDP::MyMcSocket::connected().
|
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.
t | Time to use when creating file name. |
exact | Use exact time when creating file name, else the time is adjusted to an even time interval. |
nidas::util::IOException |
Reimplemented in nidas::core::FileSet.
References nidas::core::getSample().
Referenced by nidas::core::IOStream::createFile(), and nidas::core::SampleOutputBase::createNextFile().
nidas::util::InvalidParameterException |
References nidas::core::DOMObjectFactory::createObject(), nidas::core::Socket::createSocket(), and nidas::core::getSample().
Referenced by nidas::core::DSMService::fromDOMElement(), nidas::core::SampleOutputBase::fromDOMElement(), and nidas::dynld::SampleInputStream::fromDOMElement().
Default flush implementation does nothing.
nidas::util::IOException |
Referenced by nidas::core::IOStream::flush().
nidas::util::InvalidParameterException |
Implements nidas::core::DOMable.
Reimplemented in nidas::core::MultipleUDPSockets.
References getName(), nidas::core::getSample(), isRequester(), LOG_WARNING, NIDAS_MULTICAST_ADDR, NIDAS_SVC_REQUEST_PORT_UDP, port, setInet4McastSocketAddress(), setNonBlocking(), setRequester(), and setRequestType().
Return suggested buffer length.
Reimplemented in nidas::core::DatagramSocket, nidas::core::MultipleUDPSockets, and nidas::core::Socket.
Referenced by nidas::dynld::SampleInputStream::SampleInputStream(), and nidas::dynld::SampleInputStream::SampleInputStream().
|
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().
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().
|
virtual |
Implements nidas::core::IOChannel.
Reimplemented in nidas::core::MultipleUDPSockets.
|
inline |
References _mcsocket, and nidas::util::McSocket< SocketT >::getInet4McastSocketAddress().
Referenced by nidas::core::MultipleUDPSockets::addClient().
|
inlinevirtual |
Implements nidas::core::IOChannel.
References _name.
Referenced by fromDOMElement(), and nidas::core::MultipleUDPSockets::fromDOMElement().
References nidas::core::DOMable::namespaceURI.
Referenced by nidas::dynld::UDPSampleOutput::getProjectDOM(), nidas::core::Dataset::toDOMElement(), nidas::core::ProjectConfig::toDOMElement(), nidas::core::Dataset::toDOMParent(), nidas::core::Datasets::toDOMParent(), nidas::core::ProjectConfig::toDOMParent(), nidas::core::ProjectConfigs::toDOMParent(), nidas::core::DSMConfig::toDOMParent(), nidas::core::DSMSensor::toDOMParent(), nidas::core::Project::toDOMParent(), nidas::core::SampleTag::toDOMParent(), nidas::core::Site::toDOMParent(), nidas::core::ServerSocket::toDOMParent(), nidas::core::Variable::toDOMParent(), nidas::core::Datasets::writeXML(), and nidas::core::ProjectConfigs::writeXML().
Reimplemented in nidas::core::FileSet.
Referenced by nidas::core::SampleOutputBase::getReconnectDelaySecs().
|
inlinevirtual |
Reimplemented from nidas::core::IOChannel.
References _mcsocket, and nidas::util::McSocket< SocketT >::getRequestType().
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.
|
inlinevirtual |
Return isNonBlocking() of underlying socket.
nidas::util::IOException |
Implements nidas::core::IOChannel.
References _nonBlocking.
Referenced by connect(), nidas::core::MultipleUDPSockets::connect(), and connected().
|
inline |
Does this McSocket request connections, or does it listen for incoming connections.
References _amRequester.
Referenced by connect(), fromDOMElement(), and requestConnection().
|
private |
No assignment.
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.
nidas::util::IOException |
Implements nidas::core::IOChannel.
Reimplemented in nidas::core::MultipleUDPSockets.
References nidas::core::getSample().
|
virtual |
nidas::util::IOException |
Implements nidas::core::IOChannel.
References _iochanRequester, _mcsocket, nidas::core::getSample(), isRequester(), nidas::util::McSocket< SocketT >::listen(), and nidas::util::McSocket< SocketT >::request().
|
inlinevirtualinherited |
References nidas::core::IOChannel::_conInfo, and nidas::core::getSample().
Referenced by nidas::core::Socket::connect().
What DSM is this IOChannel connected to?
References nidas::core::IOChannel::_dsm, and nidas::core::getSample().
Referenced by nidas::core::SampleOutputBase::SampleOutputBase(), and nidas::core::SampleOutputBase::setIOChannel().
|
inline |
References _mcsocket, and nidas::util::McSocket< SocketT >::setInet4McastSocketAddress().
Referenced by fromDOMElement(), and nidas::core::MultipleUDPSockets::fromDOMElement().
Implements nidas::core::IOChannel.
References _name, and nidas::core::getSample().
Referenced by McSocketUDP(), nidas::core::MultipleUDPSockets::MultipleUDPSockets(), and nidas::core::MultipleUDPSockets::MultipleUDPSockets().
Do setNonBlocking(val) on underlying socket.
nidas::util::IOException |
Implements nidas::core::IOChannel.
References _nonBlocking, and nidas::core::getSample().
Referenced by fromDOMElement(), and nidas::core::MultipleUDPSockets::fromDOMElement().
References _amRequester, and nidas::core::getSample().
Referenced by fromDOMElement(), and nidas::core::MultipleUDPSockets::fromDOMElement().
|
inlinevirtual |
Reimplemented from nidas::core::IOChannel.
References _mcsocket, and nidas::util::McSocket< SocketT >::setRequestType().
Referenced by fromDOMElement(), and nidas::core::MultipleUDPSockets::fromDOMElement().
|
virtualinherited |
Add my content into a DOMElement.
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.
Referenced by nidas::core::ServerSocket::toDOMParent().
|
virtualinherited |
Create a DOMElement and append it to the parent.
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.
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.
nidas::util::IOException |
Implements nidas::core::IOChannel.
Reimplemented in nidas::core::MultipleUDPSockets.
References nidas::core::getSample().
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.
nidas::util::IOException |
Implements nidas::core::IOChannel.
Reimplemented in nidas::core::MultipleUDPSockets.
References nidas::core::getSample().
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().
|
private |
Referenced by isRequester(), and setRequester().
|
privateinherited |
|
private |
|
protected |
Referenced by connected(), and requestConnection().
|
protected |
|
private |
Referenced by isNewInput().
|
private |
Referenced by isNonBlocking(), and setNonBlocking().
|
staticprivateinherited |
Referenced by nidas::core::DOMable::getNamespaceURI().