27 #ifndef NIDAS_CORE_SOCKET_H
28 #define NIDAS_CORE_SOCKET_H
40 namespace nidas {
namespace core {
107 throw(nidas::util::IOException)
110 return std::list<nidas::util::Inet4NetworkInterface>();
136 size_t read(
void* buf,
size_t len) throw (nidas::util::IOException)
163 for (
int i =0; i < iovcnt; i++) l += iov[i].iov_len;
164 std::cerr <<
"writing, len=" << l << std::endl;
169 void close() throw (nidas::util::IOException);
225 throw(nidas::util::UnknownHostException);
231 throw(nidas::util::InvalidParameterException);
234 throw(nidas::util::InvalidParameterException);
369 size_t read(
void*,
size_t) throw (nidas::util::IOException)
378 size_t write(
const void*,
size_t) throw (nidas::util::IOException)
387 size_t write(
const struct iovec*,
int) throw (nidas::util::IOException)
393 void close() throw (nidas::util::IOException);
399 throw(nidas::util::InvalidParameterException);
402 throw(nidas::util::InvalidParameterException);
405 toDOMParent(xercesc::DOMElement* parent,
bool complete) const
406 throw(xercesc::DOMException);
409 toDOMElement(xercesc::DOMElement* node,
bool complete) const
410 throw(xercesc::DOMException);
Implementation of an IOChannel, over a ServerSocket.
Definition: Socket.h:297
size_t read(void *buf, size_t len)
Do the actual hardware read.
Definition: Socket.h:136
int getKeepAliveIdleSecs()
Get the current value of TCP_KEEPIDLE on this socket.
Definition: Socket.h:564
const std::string & getRemoteHost() const
Get the name of the remote host.
Definition: Socket.h:193
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent, bool complete) const
Create a DOMElement and append it to the parent.
Definition: Socket.cc:673
void setRequestType(enum McSocketRequest val)
Definition: Socket.h:78
A class for parsing, formatting and doing operations on time, based on Unix time conventions, where leap seconds are ignored, so that there are always 60 seconds in a minute, 3600 seconds in an hour and 86400 seconds in a day.
Definition: UTime.h:76
std::string format(bool utc, const std::string &fmt) const
Format a UTime into a string.
Definition: UTime.cc:433
IOChannelRequester * _iochanRequester
Definition: Socket.h:272
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
Socket & operator=(const Socket &)
No assignment.
const std::string & getRemoteUnixPath() const
Get the name of the remote host.
Definition: Socket.h:206
~ServerSocket()
Definition: Socket.cc:282
An interface for a socket address.
Definition: SocketAddress.h:36
McSocketRequest
Definition: Datagrams.h:34
nidas::util::Mutex _connectionMutex
Definition: Socket.h:284
int getFd() const
Definition: Socket.h:788
bool _firstRead
Definition: Socket.h:276
std::list< Inet4NetworkInterface > getInterfaces() const
Get a list of all my network interfaces.
Definition: Socket.h:582
std::list< nidas::util::Inet4NetworkInterface > getInterfaces() const
Definition: Socket.h:106
ConnectionThread * _connectionThread
Definition: Socket.h:274
void setRemoteSocketAddress(const nidas::util::SocketAddress &val)
Definition: Socket.cc:145
std::string _unixPath
Definition: Socket.h:266
size_t write(const void *buf, size_t len)
Do the actual hardware write.
Definition: Socket.h:146
void setNonBlocking(bool val)
Do setNonBlocking(val) on underlying socket.
Definition: Socket.h:116
std::string _name
Definition: Socket.h:435
void setRemoteUnixPath(const std::string &unixPath)
Set the pathname for the unix socket connection.
Definition: Socket.cc:157
void setKeepAliveIdleSecs(int val)
Do setKeepAliveIdleSecs(int secs) on underlying socket.
Definition: Socket.h:91
bool _nonBlocking
Definition: Socket.h:282
void setName(const std::string &val)
Definition: Socket.h:323
nidas::util::auto_ptr< nidas::util::SocketAddress > _remoteSockAddr
Definition: Socket.h:260
bool isNonBlocking() const
Return isNonBlocking() of underlying socket.
Definition: Socket.h:125
void requestConnection(IOChannelRequester *service)
After the IOChannel is configured, a user of IOChannel calls requestConnection to get things started...
Definition: Socket.cc:351
size_t write(const void *, size_t)
ServerSocket should never be called to do an actual write.
Definition: Socket.h:378
A stream (TCP) socket that is used to listen for connections.
Definition: Socket.h:755
void close()
Definition: Socket.cc:309
std::string _name
Definition: Socket.h:270
const std::string & getName() const
Definition: Socket.h:321
A channel for Input or Output of data.
Definition: IOChannel.h:64
int getFd() const
Fetch the file descriptor associate with this socket.
Definition: Socket.h:617
std::string _remoteHost
Definition: Socket.h:262
void setKeepAliveIdleSecs(int val)
Set the value of keepAliveIdleSecs.
Definition: Socket.h:336
ServerSocket()
Constructor.
Definition: Socket.cc:252
bool _nonBlocking
Definition: Socket.h:447
ServerSocket * clone() const
Derived classes must provide clone.
Definition: Socket.cc:304
nidas::util::Socket * _nusocket
Definition: Socket.h:268
unsigned short _remotePort
Definition: Socket.h:264
nidas::util::auto_ptr< nidas::util::SocketAddress > _localSockAddr
Definition: Socket.h:433
ServerSocket * _socket
Definition: Socket.h:420
ConnectionThread * _connectionThread
Definition: Socket.h:441
static IOChannel * createSocket(const xercesc::DOMElement *)
Create either a Socket or a McSocket from a DOMElement.
Definition: Socket.cc:490
IOChannel * connect()
Establish a connection.
Definition: Socket.cc:323
~Socket()
Definition: Socket.cc:104
const std::string & getName() const
Definition: Socket.h:177
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node, bool complete) const
Add my content into a DOMElement.
Definition: Socket.cc:686
Socket * clone() const
Derived classes must provide clone.
Definition: Socket.cc:120
enum McSocketRequest getRequestType() const
Definition: Socket.h:83
void close()
Definition: Socket.cc:125
int len
Definition: sing.cc:934
IOChannel * connect()
Establish a connection.
Definition: Socket.cc:201
bool isNonBlocking() const
Definition: Socket.h:361
int _keepAliveIdleSecs
Definition: Socket.h:280
int getKeepAliveIdleSecs() const
Return getKeepAliveIdleSecs() on underlying socket.
Definition: Socket.h:100
void fromDOMElement(const xercesc::DOMElement *)
Initialize myself from a xercesc::DOMElement.
Definition: Socket.cc:520
size_t getBufferSize() const
Return suggested buffer length.
Definition: Socket.cc:130
IOChannelRequester * _iochanRequester
Definition: Socket.h:439
Definition: IOException.h:37
bool isNonBlocking() const
Definition: Socket.h:505
Implementation of an IOChannel, over a Socket.
Definition: Socket.h:45
void setRemoteHostPort(const std::string &host, unsigned short port)
Set the hostname and port of the remote connection.
Definition: Socket.cc:150
virtual bool isNewInput() const
Some IOChannels, namely FileSet, which opens successive files, need to indicate when a read is from t...
Definition: Socket.h:72
enum McSocketRequest _requestType
Definition: Socket.h:286
size_t write(const struct iovec *iov, int iovcnt)
Do the actual hardware write.
Definition: Socket.h:158
static n_u::SerialPort port
Definition: sing.cc:68
A stream (TCP) socket.
Definition: Socket.h:430
nidas::util::ServerSocket * _servSock
Definition: Socket.h:437
int getFd() const
Definition: Socket.h:325
size_t recv(void *buf, size_t len, int flags=0)
Definition: Socket.h:619
void setName(const std::string &val)
Definition: Socket.h:179
int _keepAliveIdleSecs
Definition: Socket.h:445
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:630
nidas::util::Inet4Address getRemoteInet4Address()
Definition: Socket.cc:184
void setNonBlocking(bool val)
The blocking flag that will be set on accepted connections.
Definition: Socket.h:353
void requestConnection(IOChannelRequester *service)
After the IOChannel is configured, a user of IOChannel calls requestConnection to get things started...
Definition: Socket.cc:236
static IOChannel * createSocket(const xercesc::DOMElement *)
Create either a Socket or a McSocket from a DOMElement.
bool _newInput
Definition: Socket.h:278
ServerSocket & operator=(const ServerSocket &)
No assignment.
Socket * _socket
Definition: Socket.h:247
A C++ wrapper for a POSIX mutex.
Definition: ThreadSupport.h:154
size_t write(const struct iovec *, int)
ServerSocket should never be called to do an actual write.
Definition: Socket.h:387
size_t read(void *, size_t)
ServerSocket will never be called to do an actual read.
Definition: Socket.h:369
Definition: UnknownHostException.h:35
Interface for an object that requests connections to Inputs or Outputs.
Definition: IOChannel.h:54
void setNonBlocking(bool val)
Do fcntl system call to set O_NONBLOCK file descriptor flag on the socket.
Definition: Socket.h:500
int getFd() const
Definition: Socket.h:171
void fromDOMElement(const xercesc::DOMElement *)
Initialize myself from a xercesc::DOMElement.
Definition: Socket.cc:600
Support for IP version 4 host address.
Definition: Inet4Address.h:46
Socket()
Constructor.
Definition: Socket.cc:43
int getKeepAliveIdleSecs() const
Return keepAliveIdleSecs for this ServerSocket.
Definition: Socket.h:344
unsigned short getRemotePort() const
Definition: Socket.h:198
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:554