nidas v1.2.3
McSocketUDP.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 ** 2009, 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_MCSOCKETUDP_H
28#define NIDAS_CORE_MCSOCKETUDP_H
29
30#include "IOChannel.h"
31#include "DOMable.h"
32#include <nidas/util/McSocket.h>
33
34#include <string>
35#include <iostream>
36
37namespace nidas { namespace core {
38
46class McSocketUDP: public IOChannel {
47
48public:
49
54
60
62
63 McSocketUDP* clone() const;
64
68
72
77 bool isRequester() const { return _amRequester; }
78
79 void setRequester(bool val) { _amRequester = val; }
80
81 void setName(const std::string& val) { _name = val; }
82
83 const std::string& getName() const { return _name; }
84
89
94
95 virtual bool isNewInput() const { return _newInput; }
96
97 virtual void connected(nidas::util::DatagramSocket* sock,
98 const nidas::util::Inet4PacketInfoX& pktinfo);
99
105 void setNonBlocking(bool val)
106 {
108 }
109
115 bool isNonBlocking() const
116 {
117 return _nonBlocking;
118 }
119
127 size_t read(void*, size_t)
128 {
129 assert(false);
130 return 0;
131 }
132
140 size_t write(const void*, size_t)
141 {
142 assert(false);
143 return 0;
144 }
145
153 size_t write(const struct iovec*, int)
154 {
155 assert(false);
156 return 0;
157 }
158
162 void close();
163
164 int getFd() const;
165
169 void fromDOMElement(const xercesc::DOMElement*);
170
171 class MyMcSocket: public nidas::util::McSocket<nidas::util::DatagramSocket>
172 {
173 public:
176 const nidas::util::Inet4PacketInfoX& pktinfo)
177 {
178 _outer->connected(sock,pktinfo);
179 }
180 private:
182
186 };
187
192
197
198protected:
199
201
203
204private:
205
206 std::string _name;
207
209
211
213
215
218
219};
220
221}} // namespace nidas namespace core
222
223#endif
Interface for an object that requests connections to Inputs or Outputs.
Definition IOChannel.h:56
A channel for Input or Output of data.
Definition IOChannel.h:65
Definition McSocketUDP.h:172
void connected(nidas::util::DatagramSocket *sock, const nidas::util::Inet4PacketInfoX &pktinfo)
Virtual method that is called when a socket connection is established.
Definition McSocketUDP.h:175
MyMcSocket(nidas::core::McSocketUDP *s)
Definition McSocketUDP.h:174
MyMcSocket(const MyMcSocket &)
No copy, assignment.
MyMcSocket operator=(const MyMcSocket &)
nidas::core::McSocketUDP * _outer
Definition McSocketUDP.h:181
Implementation of an IOChannel, using nidas::util::McSocket<nidas::util::DatagramSocket> to establish...
Definition McSocketUDP.h:46
const std::string & getName() const
Definition McSocketUDP.h:83
McSocketUDP * clone() const
Derived classes must provide clone.
Definition McSocketUDP.cc:55
const nidas::util::Inet4SocketAddress & getInet4McastSocketAddress() const
Definition McSocketUDP.h:193
void fromDOMElement(const xercesc::DOMElement *)
Definition McSocketUDP.cc:109
bool _firstRead
Definition McSocketUDP.h:210
void setRequestType(enum McSocketRequest val)
Definition McSocketUDP.h:65
virtual void connected(nidas::util::DatagramSocket *sock, const nidas::util::Inet4PacketInfoX &pktinfo)
Definition McSocketUDP.cc:84
bool isNonBlocking() const
Return isNonBlocking() of underlying socket.
Definition McSocketUDP.h:115
void close()
Definition McSocketUDP.cc:98
int getFd() const
Definition McSocketUDP.cc:104
size_t write(const struct iovec *, int)
A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.
Definition McSocketUDP.h:153
bool _newInput
Definition McSocketUDP.h:212
virtual bool isNewInput() const
Some IOChannels, namely FileSet, which opens successive files, need to indicate when a read is from t...
Definition McSocketUDP.h:95
void requestConnection(IOChannelRequester *service)
Definition McSocketUDP.cc:77
void setRequester(bool val)
Definition McSocketUDP.h:79
std::string _name
Definition McSocketUDP.h:206
void setInet4McastSocketAddress(const nidas::util::Inet4SocketAddress &val)
Definition McSocketUDP.h:188
bool _nonBlocking
Definition McSocketUDP.h:214
enum McSocketRequest getRequestType() const
Definition McSocketUDP.h:69
IOChannel * connect()
Definition McSocketUDP.cc:60
size_t read(void *, size_t)
A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.
Definition McSocketUDP.h:127
void setNonBlocking(bool val)
Do setNonBlocking(val) on underlying socket.
Definition McSocketUDP.h:105
IOChannelRequester * _iochanRequester
Definition McSocketUDP.h:200
bool isRequester() const
Does this McSocket request connections, or does it listen for incoming connections.
Definition McSocketUDP.h:77
McSocketUDP()
Constructor.
Definition McSocketUDP.cc:37
size_t write(const void *, size_t)
A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.
Definition McSocketUDP.h:140
~McSocketUDP()
Definition McSocketUDP.h:61
bool _amRequester
Definition McSocketUDP.h:208
MyMcSocket _mcsocket
Definition McSocketUDP.h:202
McSocketUDP & operator=(const McSocketUDP &)
No assignment.
void setName(const std::string &val)
Definition McSocketUDP.h:81
A socket for sending or receiving datagrams, either unicast, broadcast or multicast.
Definition Socket.h:1178
Definition Inet4PacketInfo.h:93
A IP version 4 socket address, containing a host address, and a port number.
Definition Inet4SocketAddress.h:41
A McSocket provides a way to establish a TCP stream socket connection, or a pair of UDP datagram sock...
Definition McSocket.h:192
int getRequestType() const
Get the request type number.
Definition McSocket.h:333
const Inet4SocketAddress & getInet4McastSocketAddress() const
Get the multicast address for listening to requests.
Definition McSocket.h:311
void setInet4McastSocketAddress(const Inet4SocketAddress &val)
Set the multicast address for listening to requests.
Definition McSocket.h:320
void setRequestType(int val)
Set the request type value.
Definition McSocket.h:328
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
McSocketRequest
Definition Datagrams.h:34
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31