nidas v1.2.3
TCPSocketIODevice.h
Go to the documentation of this file.
1// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2// vim: set shiftwidth=4 softtabstop=4 expandtab:
3/*
4 ********************************************************************
5 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2008, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26#ifndef NIDAS_CORE_TCPSOCKETIODEVICE_H
27#define NIDAS_CORE_TCPSOCKETIODEVICE_H
28
29#include "SocketIODevice.h"
30
31namespace nidas { namespace core {
32
37
38public:
39
45
47
56 void open(int flags);
57
61 int getReadFd() const
62 {
63 if (_socket) return _socket->getFd();
64 return -1;
65 }
66
70 int getWriteFd() const {
71 if (_socket) return _socket->getFd();
72 return -1;
73 }
74
80 size_t read(void *buf, size_t len)
81 {
82 return _socket->recv(buf,len);
83 }
84
90 size_t read(void *buf, size_t len, int msecTimeout);
91
97 size_t write(const void *buf, size_t len)
98 {
99 return _socket->send(buf,len);
100 }
101
107 void close();
108
112 void setTcpNoDelay(bool val)
113 {
115 }
116
121 {
122 return _tcpNoDelay;
123 }
124
129 {
131 }
132
137 {
138 return _keepAliveIdleSecs;
139 }
140
141protected:
142
150
152
154
159
164
165};
166
167}} // namespace nidas namespace core
168
169#endif
A IODevice providing support for UDP and TCP sockets.
Definition SocketIODevice.h:40
An IODevice consisting of a TCP socket.
Definition TCPSocketIODevice.h:36
int getReadFd() const
The file descriptor used when reading from this SocketIODevice.
Definition TCPSocketIODevice.h:61
TCPSocketIODevice()
Create a TCPSocketIODevice.
Definition TCPSocketIODevice.cc:36
int getKeepAliveIdleSecs() const
Definition TCPSocketIODevice.h:136
int getWriteFd() const
The file descriptor used when writing to this device.
Definition TCPSocketIODevice.h:70
size_t write(const void *buf, size_t len)
Write to the device.
Definition TCPSocketIODevice.h:97
bool _tcpNoDelay
Definition TCPSocketIODevice.h:151
~TCPSocketIODevice()
Definition TCPSocketIODevice.cc:42
TCPSocketIODevice & operator=(const TCPSocketIODevice &)
No assignment.
void setTcpNoDelay(bool val)
Definition TCPSocketIODevice.h:112
void close()
close the device.
Definition TCPSocketIODevice.cc:47
nidas::util::Socket * _socket
The socket.
Definition TCPSocketIODevice.h:149
void open(int flags)
Open the socket, which does a socket connect to the remote address which is parsed from the contents ...
Definition TCPSocketIODevice.cc:58
void setKeepAliveIdleSecs(int val)
Definition TCPSocketIODevice.h:128
bool getTcpNoDelay()
Definition TCPSocketIODevice.h:120
TCPSocketIODevice(const TCPSocketIODevice &)
No copy.
size_t read(void *buf, size_t len)
Read from the device.
Definition TCPSocketIODevice.h:80
int _keepAliveIdleSecs
Definition TCPSocketIODevice.h:153
A stream (TCP) socket.
Definition Socket.h:573
size_t recv(void *buf, size_t len, int flags=0)
Definition Socket.h:813
int getFd() const
Fetch the file descriptor associate with this socket.
Definition Socket.h:805
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
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
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948