nidas v1.2.3
UDPSocketIODevice.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_UDPSOCKETIODEVICE_H
27#define NIDAS_CORE_UDPSOCKETIODEVICE_H
28
29#include <nidas/util/Socket.h>
30#include "SocketIODevice.h"
31
32#include <iostream>
33
34namespace nidas { namespace core {
35
40
41public:
42
48
50
59 void open(int flags);
60
64 int getReadFd() const
65 {
66 if (_socket) return _socket->getFd();
67 return -1;
68 }
69
73 int getWriteFd() const {
74 if (_socket) return _socket->getFd();
75 return -1;
76 }
77
83 size_t read(void *buf, size_t len)
84 {
85 return _socket->recv(buf,len);
86 }
87
93 size_t read(void *buf, size_t len, int msecTimeout);
94
100 size_t write(const void *buf, size_t len)
101 {
102 return _socket->send(buf,len);
103 }
104
110 void close();
111
112protected:
113
121
126
131
132};
133
134}} // namespace nidas namespace core
135
136#endif
A IODevice providing support for UDP and TCP sockets.
Definition SocketIODevice.h:40
An IODevice consisting of an UDP socket.
Definition UDPSocketIODevice.h:39
UDPSocketIODevice & operator=(const UDPSocketIODevice &)
No assignment.
nidas::util::DatagramSocket * _socket
The datagramsocket.
Definition UDPSocketIODevice.h:120
size_t read(void *buf, size_t len)
Read from the device.
Definition UDPSocketIODevice.h:83
UDPSocketIODevice()
Create a UDPSocketIODevice.
Definition UDPSocketIODevice.cc:36
~UDPSocketIODevice()
Definition UDPSocketIODevice.cc:41
void close()
close the device.
Definition UDPSocketIODevice.cc:46
int getReadFd() const
The file descriptor used when reading from this SocketIODevice.
Definition UDPSocketIODevice.h:64
int getWriteFd() const
The file descriptor used when writing to this device.
Definition UDPSocketIODevice.h:73
void open(int flags)
Open the socket, which does a socket bind to the remote address which is parsed from the contents of ...
Definition UDPSocketIODevice.cc:57
size_t write(const void *buf, size_t len)
Write to the device.
Definition UDPSocketIODevice.h:100
UDPSocketIODevice(const UDPSocketIODevice &)
No copy.
A socket for sending or receiving datagrams, either unicast, broadcast or multicast.
Definition Socket.h:1178
size_t recv(void *buf, size_t len, int flags=0)
Definition Socket.h:1356
int getFd() const
Definition Socket.h:1312
void send(const DatagramPacketBase &packet, int flags=0)
Definition Socket.h:1348
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948