nidas v1.2.3
McSocket.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 ** 2005, 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_MCSOCKET_H
28#define NIDAS_CORE_MCSOCKET_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
43class McSocket: public IOChannel
44{
45public:
46
50 McSocket();
51
53 }
54
55 McSocket* clone() const;
56
60
64
69 bool isRequester() const { return _amRequester; }
70
71 void setRequester(bool val) { _amRequester = val; }
72
73 void setName(const std::string& val) { _name = val; }
74
75 const std::string& getName() const { return _name; }
76
81
86
87 virtual void connected(nidas::util::Socket* sock,
88 const nidas::util::Inet4PacketInfoX& pktinfo);
89
90 virtual bool isNewInput() const { return _newInput; }
91
92 // nidas::util::Inet4Address getRemoteInet4Address();
93
98 {
100 }
101
106 {
107 return _keepAliveIdleSecs;
108 }
109
115 void setNonBlocking(bool val)
116 {
118 }
119
125 bool isNonBlocking() const
126 {
127 return _nonBlocking;
128 }
129
137 size_t read(void*, size_t)
138 {
139 assert(false);
140 return 0;
141 }
142
150 size_t write(const void*, size_t)
151 {
152 assert(false);
153 return 0;
154 }
155
163 size_t write(const struct iovec*, int)
164 {
165 assert(false);
166 return 0;
167 }
168
172 void close();
173
174 int getFd() const;
175
179 void fromDOMElement(const xercesc::DOMElement*);
180
181 class MyMcSocket: public nidas::util::McSocket<nidas::util::Socket>
182 {
183 public:
186 {
187 _outer->connected(sock,pktinfo);
188 }
189 private:
193 };
194
199
204
205protected:
206
211 McSocket(const McSocket&);
212
214
216
217private:
218
219 std::string _name;
220
222
224
226
228
230
235};
236
237
238}} // namespace nidas namespace core
239
240#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 McSocket.h:182
void connected(nidas::util::Socket *sock, const nidas::util::Inet4PacketInfoX &pktinfo)
Virtual method that is called when a socket connection is established.
Definition McSocket.h:185
MyMcSocket(nidas::core::McSocket *s)
Definition McSocket.h:184
MyMcSocket(const MyMcSocket &)
nidas::core::McSocket * _outer
Definition McSocket.h:190
MyMcSocket & operator=(const MyMcSocket &)
Implementation of an IOChannel, using nidas::util::McSocket<nidas::util::Socket> to establish a TCP c...
Definition McSocket.h:44
MyMcSocket _mcsocket
Definition McSocket.h:215
virtual void connected(nidas::util::Socket *sock, const nidas::util::Inet4PacketInfoX &pktinfo)
Definition McSocket.cc:93
McSocket()
Constructor.
Definition McSocket.cc:41
bool isRequester() const
Does this McSocket request connections, or does it listen for incoming connections.
Definition McSocket.h:69
int getKeepAliveIdleSecs() const
Definition McSocket.h:105
IOChannelRequester * _iochanRequester
Definition McSocket.h:213
std::string _name
Definition McSocket.h:219
bool _firstRead
Definition McSocket.h:223
McSocket * clone() const
Derived classes must provide clone.
Definition McSocket.cc:60
void setName(const std::string &val)
Definition McSocket.h:73
void setKeepAliveIdleSecs(int val)
Definition McSocket.h:97
void setInet4McastSocketAddress(const nidas::util::Inet4SocketAddress &val)
Definition McSocket.h:195
void fromDOMElement(const xercesc::DOMElement *)
Definition McSocket.cc:122
void setRequester(bool val)
Definition McSocket.h:71
int _keepAliveIdleSecs
Definition McSocket.h:227
bool isNonBlocking() const
Return isNonBlocking() of underlying socket.
Definition McSocket.h:125
enum McSocketRequest getRequestType() const
Definition McSocket.h:61
void requestConnection(IOChannelRequester *service)
Definition McSocket.cc:86
~McSocket()
Definition McSocket.h:52
size_t write(const struct iovec *, int)
A McSocket shouldn't be used to do any actual reads or writes, it just sets up the connection.
Definition McSocket.h:163
void close()
Definition McSocket.cc:111
const nidas::util::Inet4SocketAddress & getInet4McastSocketAddress() const
Definition McSocket.h:200
McSocket & operator=(const McSocket &)
No assignment.
int getFd() const
Definition McSocket.cc:117
size_t read(void *, size_t)
A McSocket shouldn't be used to do any actual reads or writes, it just sets up the connection.
Definition McSocket.h:137
void setNonBlocking(bool val)
Do setNonBlocking(val) on underlying socket.
Definition McSocket.h:115
virtual bool isNewInput() const
Some IOChannels, namely FileSet, which opens successive files, need to indicate when a read is from t...
Definition McSocket.h:90
void setRequestType(enum McSocketRequest val)
Definition McSocket.h:57
bool _amRequester
Definition McSocket.h:221
IOChannel * connect()
Definition McSocket.cc:65
const std::string & getName() const
Definition McSocket.h:75
size_t write(const void *, size_t)
A McSocket shouldn't be used to do any actual reads or writes, it just sets up the connection.
Definition McSocket.h:150
bool _nonBlocking
Definition McSocket.h:229
bool _newInput
Definition McSocket.h:225
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
A stream (TCP) socket.
Definition Socket.h:573
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