Remote Call Framework 3.3
UnixLocalClientTransport.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2022, Delta V Software. All rights reserved.
6 // https://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 under GPL terms.
12 //
13 // Version: 3.3
14 // Contact: support <at> deltavsoft.com
15 //
16 //******************************************************************************
17 
18 #ifndef INCLUDE_RCF_UNIXLOCALCLIENTTRANSPORT_HPP
19 #define INCLUDE_RCF_UNIXLOCALCLIENTTRANSPORT_HPP
20 
21 #if defined(RCF_WINDOWS)
22 #error Unix domain sockets not supported on Windows.
23 #endif
24 
25 #include <RCF/BsdClientTransport.hpp>
26 #include <RCF/Export.hpp>
27 #include <RCF/IpClientTransport.hpp>
28 
29 #include <sys/un.h>
30 
31 namespace RCF {
32 
33  using ASIO_NS::local::stream_protocol;
34  typedef stream_protocol::socket UnixLocalSocket;
35  typedef std::shared_ptr<UnixLocalSocket> UnixLocalSocketPtr;
36 
37  class RCF_EXPORT UnixLocalClientTransport :
38  public BsdClientTransport
39  {
40  public:
41  UnixLocalClientTransport(const UnixLocalClientTransport &rhs);
42  UnixLocalClientTransport(const std::string &fileName);
43  UnixLocalClientTransport(const sockaddr_un &remoteAddr);
44  UnixLocalClientTransport(UnixLocalSocketPtr socketPtr, const std::string & fileName);
45 
46  ~UnixLocalClientTransport();
47 
48  TransportType getTransportType();
49 
50  ClientTransportUniquePtr clone() const;
51 
52  void implConnect(unsigned int timeoutMs);
53 
54  void implConnect(
55  ClientTransportCallback &clientStub,
56  unsigned int timeoutMs);
57 
58  void implConnectAsync(
59  ClientTransportCallback &clientStub,
60  unsigned int timeoutMs);
61 
62  void implClose();
63  EndpointPtr getEndpointPtr() const;
64 
65  void setRemoteAddr(const sockaddr_un &remoteAddr);
66  const sockaddr_un & getRemoteAddr() const;
67 
68  bool isAssociatedWithIoService();
69  void associateWithIoService(AsioIoService & ioService);
70 
71  std::string getPipeName() const;
72 
73  private:
74 
75  void setupSocket();
76  void setupSocket(Exception & e);
77 
78  sockaddr_un mRemoteAddr;
79  const std::string mFileName;
80  };
81 
82 } // namespace RCF
83 
84 #endif // ! INCLUDE_RCF_UNIXLOCALCLIENTTRANSPORT_HPP
std::shared_ptr< Endpoint > EndpointPtr
Reference counted wrapper for RCF::Endpoint.
Definition: RcfFwd.hpp:117
std::unique_ptr< ClientTransport > ClientTransportUniquePtr
Unique pointer wrapper for RCF::ClientTransport.
Definition: RcfFwd.hpp:43
Definition: AmiIoHandler.hpp:23
TransportType
Describes the transport types used by a RCF connection.
Definition: Enums.hpp:33