RCFProto

- Main Page
- Classes
- Files

- File List

All Classes Functions Typedefs
BsdClientTransport.hpp
1
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2013, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 2.0
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18
19 #ifndef INCLUDE_RCF_BSDCLIENTTRANSPORT_HPP
20 #define INCLUDE_RCF_BSDCLIENTTRANSPORT_HPP
21
22 #include <RCF/Export.hpp>
23 #include <RCF/ConnectionOrientedClientTransport.hpp>
24
25 #include <boost/scoped_ptr.hpp>
26
27 namespace RCF {
28
29 typedef AsioSocket TcpSocket;
30 typedef boost::shared_ptr<TcpSocket> TcpSocketPtr;
31
32 #ifdef RCF_HAS_LOCAL_SOCKETS
33
34 using ASIO_NS::local::stream_protocol;
35 typedef stream_protocol::socket UnixLocalSocket;
36 typedef boost::shared_ptr<UnixLocalSocket> UnixLocalSocketPtr;
37
38 #else
39
40 typedef TcpSocket UnixLocalSocket;
41 typedef TcpSocketPtr UnixLocalSocketPtr;
42
43 #endif
44
45 class RCF_EXPORT BsdClientTransport :
46 public ConnectionOrientedClientTransport
47 {
48 public:
49
50 BsdClientTransport();
51 BsdClientTransport(const BsdClientTransport & rhs);
52 BsdClientTransport(TcpSocketPtr socketPtr);
53
54 #ifdef RCF_HAS_LOCAL_SOCKETS
55 BsdClientTransport(UnixLocalSocketPtr socketPtr);
56 #endif
57
58 ~BsdClientTransport();
59
60 TcpSocketPtr releaseTcpSocket();
61 UnixLocalSocketPtr releaseLocalSocket();
62
63 int getNativeHandle() const;
64
65 private:
66
67 std::size_t implRead(
68 const ByteBuffer &byteBuffer,
69 std::size_t bytesRequested);
70
71 std::size_t implReadAsync(
72 const ByteBuffer &byteBuffer,
73 std::size_t bytesRequested);
74
75 std::size_t implWrite(
76 const std::vector<ByteBuffer> &byteBuffers);
77
78 std::size_t implWriteAsync(
79 const std::vector<ByteBuffer> &byteBuffers);
80
81 bool isConnected();
82
83 protected:
84
85 int mFd;
86 TcpSocketPtr mTcpSocketPtr;
87 UnixLocalSocketPtr mLocalSocketPtr;
88
89 AsioBuffersPtr mAsioBuffersPtr;
90 AsioIoService * mpIoService;
91
92 int mWriteCounter;
93 };
94
95 } // namespace RCF
96
97 #endif // ! INCLUDE_RCF_TCPCLIENTTRANSPORT_HPP