nidas v1.2.3
MultipleUDPSockets.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_MULTIPLESOCKETUDP_H
28#define NIDAS_CORE_MULTIPLESOCKETUDP_H
29
30#include "McSocketUDP.h"
31
32#include <string>
33#include <iostream>
34
35namespace nidas { namespace core {
36
38{
39public:
41
43
45
50
52 const nidas::util::Inet4PacketInfoX& pktinfo) throw();
53
54 size_t getBufferSize() const throw();
55
59 size_t read(void*, size_t)
60 {
61 assert(false);
62 return 0;
63 }
64
68 size_t write(const void* buf, size_t len);
69
73 size_t write(const struct iovec* iov, int iovcnt);
74
78 void close();
79
80 int getFd() const;
81
85 void fromDOMElement(const xercesc::DOMElement*);
86
97 void addClient(const ConnectionInfo& info);
98
99 void removeClient(const nidas::util::Inet4SocketAddress& remoteSAddr);
100
102
103 void setDataPort(unsigned short val)
104 {
105 _dataPortNumber = htons(val);
106 }
107
108 unsigned short getDataPort() const
109 {
110 return ntohs(_dataPortNumber);
111 }
112
113private:
114
116
118
119 std::list<std::pair<nidas::util::DatagramSocket*,nidas::util::Inet4SocketAddress> > _sockets;
120
121 std::list<std::pair<nidas::util::DatagramSocket*,nidas::util::Inet4SocketAddress> > _pendingSockets;
122
123 std::list<nidas::util::DatagramSocket*> _pendingRemoveSockets;
124
128 std::map<nidas::util::Inet4SocketAddress,nidas::util::Inet4Address>
130
134 std::map<nidas::util::Inet4Address,std::set<nidas::util::Inet4SocketAddress> >
136
140 std::map<nidas::util::Inet4Address,nidas::util::DatagramSocket*>
142
146 std::map<nidas::util::Inet4SocketAddress,nidas::util::DatagramSocket*>
148
150
151 unsigned short _dataPortNumber;
152};
153
154
155}} // namespace nidas namespace core
156
157#endif
Extra information associated with an IOChannel concerning the connection.
Definition ConnectionInfo.h:39
A channel for Input or Output of data.
Definition IOChannel.h:65
Implementation of an IOChannel, using nidas::util::McSocket<nidas::util::DatagramSocket> to establish...
Definition McSocketUDP.h:46
Definition MultipleUDPSockets.h:38
std::list< std::pair< nidas::util::DatagramSocket *, nidas::util::Inet4SocketAddress > > _sockets
Definition MultipleUDPSockets.h:119
std::map< nidas::util::Inet4SocketAddress, nidas::util::DatagramSocket * > _unicastSockets
Unicast Sockets for each destination.
Definition MultipleUDPSockets.h:147
std::list< std::pair< nidas::util::DatagramSocket *, nidas::util::Inet4SocketAddress > > _pendingSockets
Definition MultipleUDPSockets.h:121
unsigned short getDataPort() const
Definition MultipleUDPSockets.h:108
void removeClient(const nidas::util::Inet4SocketAddress &remoteSAddr)
Definition MultipleUDPSockets.cc:167
void close()
Definition MultipleUDPSockets.cc:338
std::list< nidas::util::DatagramSocket * > _pendingRemoveSockets
Definition MultipleUDPSockets.h:123
MultipleUDPSockets()
Definition MultipleUDPSockets.cc:36
int getFd() const
Definition MultipleUDPSockets.cc:353
std::map< nidas::util::Inet4SocketAddress, nidas::util::Inet4Address > _multicastInterfaces
The local multicast interface of each remote client.
Definition MultipleUDPSockets.h:129
std::map< nidas::util::Inet4Address, nidas::util::DatagramSocket * > _multicastSockets
Socket of each multicast interface.
Definition MultipleUDPSockets.h:141
MultipleUDPSockets * clone() const
Derived classes must provide clone.
Definition MultipleUDPSockets.cc:59
size_t read(void *, size_t)
Definition MultipleUDPSockets.h:59
unsigned short _dataPortNumber
Definition MultipleUDPSockets.h:151
size_t write(const void *buf, size_t len)
Definition MultipleUDPSockets.cc:296
void connected(nidas::util::DatagramSocket *sock, const nidas::util::Inet4PacketInfoX &pktinfo)
Definition MultipleUDPSockets.cc:81
void handleChangedSockets()
Definition MultipleUDPSockets.cc:271
void fromDOMElement(const xercesc::DOMElement *)
Definition MultipleUDPSockets.cc:363
IOChannel * connect()
Definition MultipleUDPSockets.cc:64
std::map< nidas::util::Inet4Address, std::set< nidas::util::Inet4SocketAddress > > _multicastClients
Remote clients of each multicast interface.
Definition MultipleUDPSockets.h:135
void setDataPort(unsigned short val)
Definition MultipleUDPSockets.h:103
size_t getBufferSize() const
Return suggested buffer length.
Definition MultipleUDPSockets.cc:256
void addClient(const ConnectionInfo &info)
From the Inet4PacketInfoX associated with the received request, determine if we need to create a new ...
Definition MultipleUDPSockets.cc:98
nidas::util::Mutex _socketMutex
Definition MultipleUDPSockets.h:117
bool _socketsChanged
Definition MultipleUDPSockets.h:149
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 C++ wrapper for a POSIX mutex.
Definition ThreadSupport.h:161
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
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948