27#ifndef NIDAS_CORE_SOCKET_H
28#define NIDAS_CORE_SOCKET_H
40namespace nidas {
namespace core {
121 return std::list<nidas::util::Inet4NetworkInterface>();
179 size_t write(
const struct iovec* iov,
int iovcnt)
184 for (
int i =0; i <
iovcnt; i++) l += iov[i].iov_len;
185 std::cerr <<
"writing, len=" << l << std::endl;
431 size_t write(
const struct iovec*,
int)
458 toDOMParent(xercesc::DOMElement* parent,
bool complete)
const;
464 toDOMElement(xercesc::DOMElement* node,
bool complete)
const;
Interface for an object that requests connections to Inputs or Outputs.
Definition IOChannel.h:56
A channel for Input or Output of data.
Definition IOChannel.h:65
ConnectionThread(const ConnectionThread &)
void interrupt()
Interrupt this thread.
Definition Socket.cc:384
ConnectionThread & operator=(const ConnectionThread &)
int run()
The method which will run in its own thread.
Definition Socket.cc:390
ConnectionThread(ServerSocket *sock)
Definition Socket.cc:377
ServerSocket * _socket
Definition Socket.h:474
Implementation of an IOChannel, over a ServerSocket.
Definition Socket.h:325
void close()
Definition Socket.cc:307
ConnectionThread * _connectionThread
Definition Socket.h:495
IOChannel * connect()
Definition Socket.cc:321
void fromDOMElement(const xercesc::DOMElement *)
Definition Socket.cc:595
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node, bool complete) const
Definition Socket.cc:679
ServerSocket * clone() const
Derived classes must provide clone.
Definition Socket.cc:302
ServerSocket()
Constructor.
Definition Socket.cc:250
int getKeepAliveIdleSecs() const
Return keepAliveIdleSecs for this ServerSocket.
Definition Socket.h:380
int _keepAliveIdleSecs
Definition Socket.h:499
const std::string & getName() const
Definition Socket.h:353
void setNonBlocking(bool val)
The blocking flag that will be set on accepted connections.
Definition Socket.h:391
~ServerSocket()
Definition Socket.cc:280
bool isNonBlocking() const
Definition Socket.h:399
void setName(const std::string &val)
Definition Socket.h:355
void setKeepAliveIdleSecs(int val)
Set the value of keepAliveIdleSecs.
Definition Socket.h:370
std::string _name
Definition Socket.h:489
IOChannelRequester * _iochanRequester
Definition Socket.h:493
nidas::util::ServerSocket * _servSock
Definition Socket.h:491
int getFd() const
Definition Socket.h:357
size_t read(void *, size_t)
ServerSocket will never be called to do an actual read.
Definition Socket.h:409
ServerSocket & operator=(const ServerSocket &)
No assignment.
size_t write(const void *, size_t)
ServerSocket should never be called to do an actual write.
Definition Socket.h:420
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent, bool complete) const
Definition Socket.cc:667
size_t write(const struct iovec *, int)
ServerSocket should never be called to do an actual write.
Definition Socket.h:431
nidas::util::auto_ptr< nidas::util::SocketAddress > _localSockAddr
Definition Socket.h:487
void requestConnection(IOChannelRequester *service)
Definition Socket.cc:349
bool _nonBlocking
Definition Socket.h:501
static IOChannel * createSocket(const xercesc::DOMElement *)
Create either a Socket or a McSocket from a DOMElement.
ConnectionThread(const ConnectionThread &)
void interrupt()
Interrupt this thread.
Definition Socket.cc:427
ConnectionThread(Socket *sock)
Definition Socket.cc:416
Socket * _socket
Definition Socket.h:275
ConnectionThread & operator=(const ConnectionThread &)
~ConnectionThread()
Definition Socket.cc:421
int run()
The method which will run in its own thread.
Definition Socket.cc:434
Implementation of an IOChannel, over a Socket.
Definition Socket.h:45
int getKeepAliveIdleSecs() const
Return getKeepAliveIdleSecs() on underlying socket.
Definition Socket.h:109
void setRemoteSocketAddress(const nidas::util::SocketAddress &val)
Definition Socket.cc:145
std::string _name
Definition Socket.h:298
const std::string & getRemoteHost() const
Get the name of the remote host.
Definition Socket.h:217
std::string _remoteHost
Definition Socket.h:290
void setKeepAliveIdleSecs(int val)
Do setKeepAliveIdleSecs(int secs) on underlying socket.
Definition Socket.h:98
int getFd() const
Definition Socket.h:195
size_t write(const struct iovec *iov, int iovcnt)
Do the actual hardware write.
Definition Socket.h:179
std::string _unixPath
Definition Socket.h:294
void fromDOMElement(const xercesc::DOMElement *)
Definition Socket.cc:516
Socket & operator=(const Socket &)
No assignment.
std::list< nidas::util::Inet4NetworkInterface > getInterfaces() const
Definition Socket.h:118
void requestConnection(IOChannelRequester *service)
Definition Socket.cc:235
size_t getBufferSize() const
Return suggested buffer length.
Definition Socket.cc:130
enum McSocketRequest _requestType
Definition Socket.h:314
enum McSocketRequest getRequestType() const
Definition Socket.h:88
void setNonBlocking(bool val)
Do setNonBlocking(val) on underlying socket.
Definition Socket.h:129
Socket * clone() const
Derived classes must provide clone.
Definition Socket.cc:120
bool _nonBlocking
Definition Socket.h:310
void setRemoteUnixPath(const std::string &unixPath)
Set the pathname for the unix socket connection.
Definition Socket.cc:157
ConnectionThread * _connectionThread
Definition Socket.h:302
int _keepAliveIdleSecs
Definition Socket.h:308
nidas::util::Socket * _nusocket
Definition Socket.h:296
bool _firstRead
Definition Socket.h:304
const std::string & getRemoteUnixPath() const
Get the name of the remote host.
Definition Socket.h:230
bool _newInput
Definition Socket.h:306
IOChannel * connect()
Definition Socket.cc:200
void close()
Definition Socket.cc:125
size_t read(void *buf, size_t len)
Do the actual hardware read.
Definition Socket.h:153
nidas::util::Mutex _connectionMutex
Definition Socket.h:312
Socket()
Constructor.
Definition Socket.cc:43
const nidas::util::SocketAddress & getRemoteSocketAddress()
This method does a DNS lookup of the value of getRemoteHost(), and so it can throw an UnknownHostExce...
Definition Socket.cc:162
void setRemoteHostPort(const std::string &host, unsigned short port)
Set the hostname and port of the remote connection.
Definition Socket.cc:150
IOChannelRequester * _iochanRequester
Definition Socket.h:300
static IOChannel * createSocket(const xercesc::DOMElement *)
Create either a Socket or a McSocket from a DOMElement.
Definition Socket.cc:487
bool isNonBlocking() const
Return isNonBlocking() of underlying socket.
Definition Socket.h:140
void setRequestType(enum McSocketRequest val)
Definition Socket.h:83
nidas::util::Inet4Address getRemoteInet4Address()
Definition Socket.cc:183
virtual bool isNewInput() const
Some IOChannels, namely FileSet, which opens successive files, need to indicate when a read is from t...
Definition Socket.h:77
void setName(const std::string &val)
Definition Socket.h:203
nidas::util::auto_ptr< nidas::util::SocketAddress > _remoteSockAddr
Definition Socket.h:288
const std::string & getName() const
Definition Socket.h:201
size_t write(const void *buf, size_t len)
Do the actual hardware write.
Definition Socket.h:165
~Socket()
Definition Socket.cc:104
unsigned short _remotePort
Definition Socket.h:292
unsigned short getRemotePort() const
Definition Socket.h:222
Support for IP version 4 host address.
Definition Inet4Address.h:46
A C++ wrapper for a POSIX mutex.
Definition ThreadSupport.h:161
A stream (TCP) socket that is used to listen for connections.
Definition Socket.h:981
int getFd() const
Definition Socket.h:1019
An interface for a socket address.
Definition SocketAddress.h:36
A stream (TCP) socket.
Definition Socket.h:573
void setNonBlocking(bool val)
Do fcntl system call to set O_NONBLOCK file descriptor flag on the socket.
Definition Socket.h:658
int getKeepAliveIdleSecs()
Get the current value of TCP_KEEPIDLE on this socket.
Definition Socket.h:740
size_t recv(void *buf, size_t len, int flags=0)
Definition Socket.h:813
std::list< Inet4NetworkInterface > getInterfaces() const
Get a list of all my network interfaces.
Definition Socket.h:766
int getFd() const
Fetch the file descriptor associate with this socket.
Definition Socket.h:805
void setKeepAliveIdleSecs(int val)
Set the number of seconds a connection needs to be idle before TCP begins sending out keep-alive prob...
Definition Socket.h:728
bool isNonBlocking() const
Definition Socket.h:666
size_t send(const void *buf, size_t len, int flags=MSG_NOSIGNAL)
send data on socket, see man page for send system function.
Definition Socket.h:826
A class for parsing, formatting and doing operations on time, based on Unix time conventions,...
Definition UTime.h:95
std::string format(bool utc, const std::string &fmt) const
Format a UTime into a string.
Definition UTime.cc:462
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
McSocketRequest
Definition Datagrams.h:34
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
static n_u::SerialPort port
Definition sing.cc:68
int len
Definition sing.cc:948