This is Unofficial EPICS BASE Doxygen Site
blockingTCP.h
Go to the documentation of this file.
1 
7 #ifndef BLOCKINGTCP_H_
8 #define BLOCKINGTCP_H_
9 
10 #include <set>
11 #include <map>
12 #include <deque>
13 
14 #ifdef epicsExportSharedSymbols
15 # define blockingTCPEpicsExportSharedSymbols
16 # undef epicsExportSharedSymbols
17 #endif
18 
19 #include <shareLib.h>
20 #include <osiSock.h>
21 #include <epicsTime.h>
22 #include <epicsThread.h>
23 
24 #include <pv/byteBuffer.h>
25 #include <pv/pvType.h>
26 #include <pv/lock.h>
27 #include <pv/timer.h>
28 #include <pv/event.h>
29 
30 #ifdef blockingTCPEpicsExportSharedSymbols
31 # define epicsExportSharedSymbols
32 # undef blockingTCPEpicsExportSharedSymbols
33 #endif
34 
35 #include <pv/pvaConstants.h>
36 #include <pv/remote.h>
37 #include <pv/transportRegistry.h>
39 #include <pv/inetAddressUtil.h>
40 
41 namespace epics {
42 namespace pvAccess {
43 
44 class ClientChannelImpl;
45 
52 public:
54 
55  BlockingTCPConnector(Context::shared_pointer const & context, int receiveBufferSize,
56  float beaconInterval);
57 
58  Transport::shared_pointer connect(std::tr1::shared_ptr<ClientChannelImpl> const & client,
59  ResponseHandler::shared_pointer const & responseHandler, osiSockAddr& address,
60  epics::pvData::int8 transportRevision, epics::pvData::int16 priority);
61 private:
65  static const int LOCK_TIMEOUT = 20*1000; // 20s
66 
70  Context::weak_pointer _context;
71 
75  int _receiveBufferSize;
76 
80  float _heartbeatInterval;
81 
89  SOCKET tryConnect(osiSockAddr& address, int tries);
90 
91 };
92 
98 class BlockingTCPAcceptor : public epicsThreadRunable {
99 public:
101 
102  BlockingTCPAcceptor(Context::shared_pointer const & context,
103  ResponseHandler::shared_pointer const & responseHandler,
104  const osiSockAddr& addr, int receiveBufferSize);
105 
106  virtual ~BlockingTCPAcceptor();
107 
113  return &_bindAddress;
114  }
115 
119  void destroy();
120 
121 private:
122  virtual void run();
123 
127  Context::shared_pointer _context;
128 
132  ResponseHandler::shared_pointer _responseHandler;
133 
137  osiSockAddr _bindAddress;
138 
142  SOCKET _serverSocketChannel;
143 
147  int _receiveBufferSize;
148 
152  bool _destroyed;
153 
154  epics::pvData::Mutex _mutex;
155 
156  epicsThread _thread;
157 
162  int initialize();
163 
168  bool validateConnection(Transport::shared_pointer const & transport, const char* address);
169 };
170 
171 }
172 }
173 
174 #endif /* BLOCKINGTCP_H_ */
int8_t int8
Definition: pvType.h:75
BlockingTCPConnector(Context::shared_pointer const &context, int receiveBufferSize, float beaconInterval)
Transport::shared_pointer connect(std::tr1::shared_ptr< ClientChannelImpl > const &client, ResponseHandler::shared_pointer const &responseHandler, osiSockAddr &address, epics::pvData::int8 transportRevision, epics::pvData::int16 priority)
POINTER_DEFINITIONS(BlockingTCPConnector)
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
#define initialize
Definition: aaiRecord.c:54
Mark external symbols and entry points for shared libraries.
Definition: server.h:76
int SOCKET
Definition: osdSock.h:31
const osiSockAddr * getBindAddress()
Definition: blockingTCP.h:112
int16_t int16
Definition: pvType.h:79
EPICS time-stamps (epicsTimeStamp), epicsTime C++ class and C functions for handling wall-clock times...
epicsMutex Mutex
Definition: lock.h:28
C++ and C descriptions for a thread.