pvAccessCPP  7.1.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
blockingTCP.h
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>
38 #include <pv/introspectionRegistry.h>
39 #include <pv/inetAddressUtil.h>
40 
41 namespace epics {
42 namespace pvAccess {
43 
44 class ClientChannelImpl;
45 
52 public:
53  POINTER_DEFINITIONS(BlockingTCPConnector);
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:
100  POINTER_DEFINITIONS(BlockingTCPAcceptor);
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 
112  const osiSockAddr* getBindAddress() {
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_ */
const osiSockAddr * getBindAddress()
Bind socket address.
Definition: blockingTCP.h:112
void destroy()
Destroy acceptor (stop listening).
Channel Access Server TCP acceptor.
Definition: blockingTCP.h:98
Channel Access TCP connector.
Definition: blockingTCP.h:51