nidas  v1.2-1520
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 
35 namespace nidas { namespace core {
36 
40 class SocketIODevice : public IODevice {
41 
42 public:
43 
49 
51 
61  void open(int flags)
63 
64  /*
65  * Perform an ioctl on the device. This is supported on sockets,
66  * and will throw an IOException.
67  */
68  void ioctl(int /* request */, void* /* buf */, size_t /* len */) throw(nidas::util::IOException)
69  {
71  "ioctl","not supported on SocketIODevice");
72  }
73 
88  static void parseAddress(const std::string& name, int& addrtype,std::string& hostname,
89  int& port,std::string& bindaddr) throw(nidas::util::ParseException);
90 
91 protected:
92 
96  int _addrtype;
97 
101  std::string _desthost;
102 
108  int _port;
109 
113  nidas::util::auto_ptr<nidas::util::SocketAddress> _sockAddr;
114 
118  std::string _bindAddr;
119 
120 };
121 
122 }} // namespace nidas namespace core
123 
124 #endif
void ioctl(int, void *, size_t)
Definition: SocketIODevice.h:68
void open(int flags)
Prepare to open the socket.
Definition: SocketIODevice.cc:160
A IODevice providing support for UDP and TCP sockets.
Definition: SocketIODevice.h:40
~SocketIODevice()
Definition: SocketIODevice.cc:46
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
virtual const std::string & getName() const
Definition: IODevice.h:57
An interface to an IO device.
Definition: IODevice.h:41
int _addrtype
The type of the destination address, AF_INET or AF_UNIX.
Definition: SocketIODevice.h:96
Definition: IOException.h:37
int _port
Port number that is parsed from sensor name.
Definition: SocketIODevice.h:108
static n_u::SerialPort port
Definition: sing.cc:68
std::string _desthost
Destination host name from sensor name.
Definition: SocketIODevice.h:101
nidas::util::auto_ptr< nidas::util::SocketAddress > _sockAddr
The destination socket address.
Definition: SocketIODevice.h:113
SocketIODevice()
Create a SocketIODevice.
Definition: SocketIODevice.cc:41
Definition: InvalidParameterException.h:35
std::string _bindAddr
The local bind socket address.
Definition: SocketIODevice.h:118
Definition: ParseException.h:36