nidas v1.2.3
SocketIODevice.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 ** 2006, 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
27#ifndef NIDAS_CORE_SOCKETIODEVICE_H
28#define NIDAS_CORE_SOCKETIODEVICE_H
29
30#include "IODevice.h"
31#include <nidas/util/Socket.h>
33#include <nidas/util/auto_ptr.h>
34
35namespace nidas { namespace core {
36
40class SocketIODevice : public IODevice {
41
42public:
43
49
51
64 void open(int flags);
65
66 /*
67 * Perform an ioctl on the device. This is supported on sockets,
68 * and will throw an IOException.
69 *
70 * @throws nidas::util::IOException
71 */
72 void ioctl(int /* request */, void* /* buf */, size_t /* len */)
73 {
75 "ioctl","not supported on SocketIODevice");
76 }
77
94 static void parseAddress(const std::string& name, int& addrtype,
95 std::string& hostname,
96 int& port, std::string& bindaddr);
97
98protected:
99
104
108 std::string _desthost;
109
115 int _port;
116
120 nidas::util::auto_ptr<nidas::util::SocketAddress> _sockAddr;
121
125 std::string _bindAddr;
126
127};
128
129}} // namespace nidas namespace core
130
131#endif
An interface to an IO device.
Definition IODevice.h:42
virtual const std::string & getName() const
Definition IODevice.h:57
A IODevice providing support for UDP and TCP sockets.
Definition SocketIODevice.h:40
void ioctl(int, void *, size_t)
Definition SocketIODevice.h:72
int _port
Port number that is parsed from sensor name.
Definition SocketIODevice.h:115
std::string _desthost
Destination host name from sensor name.
Definition SocketIODevice.h:108
SocketIODevice()
Create a SocketIODevice.
Definition SocketIODevice.cc:41
static void parseAddress(const std::string &name, int &addrtype, std::string &hostname, int &port, std::string &bindaddr)
Parse the getName() string to extract a socket type, destination address and optional port number.
Definition SocketIODevice.cc:51
~SocketIODevice()
Definition SocketIODevice.cc:46
std::string _bindAddr
The local bind socket address.
Definition SocketIODevice.h:125
void open(int flags)
Prepare to open the socket.
Definition SocketIODevice.cc:160
int _addrtype
The type of the destination address, AF_INET or AF_UNIX.
Definition SocketIODevice.h:103
nidas::util::auto_ptr< nidas::util::SocketAddress > _sockAddr
The destination socket address.
Definition SocketIODevice.h:120
Definition IOException.h:37
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
static n_u::SerialPort port
Definition sing.cc:68