Remote Call Framework 3.1
TcpClientTransport.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2019, 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: 3.1
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_TCPCLIENTTRANSPORT_HPP
20 #define INCLUDE_RCF_TCPCLIENTTRANSPORT_HPP
21 
22 #include <RCF/BsdClientTransport.hpp>
23 #include <RCF/Export.hpp>
24 #include <RCF/IpClientTransport.hpp>
25 
26 namespace RCF {
27 
28  class RCF_EXPORT TcpClientTransport :
29  public BsdClientTransport,
30  public IpClientTransport
31  {
32  public:
33  TcpClientTransport(const TcpClientTransport &rhs);
34  TcpClientTransport(const IpAddress &remoteAddr);
35  TcpClientTransport(const std::string & ip, int port);
36 
37  TcpClientTransport(TcpSocketPtr socketPtr);
38 
39  ~TcpClientTransport();
40 
41  TransportType getTransportType();
42 
43  ClientTransportUniquePtr clone() const;
44 
45  void implConnect(
46  ClientTransportCallback &clientStub,
47  unsigned int timeoutMs);
48 
49  void implConnectAsync(
50  ClientTransportCallback &clientStub,
51  unsigned int timeoutMs);
52 
53  void implClose();
54  EndpointPtr getEndpointPtr() const;
55 
56  void setRemoteAddr(const IpAddress &remoteAddr);
57  IpAddress getRemoteAddr() const;
58 
59 
60  bool isAssociatedWithIoService();
61  void associateWithIoService(AsioIoService & ioService);
62 
63  private:
64 
65  static void doDnsLookup(
66  std::size_t index,
67  unsigned int timeoutMs,
68  OverlappedAmiPtr overlappedPtr,
69  IpAddress ipAddress);
70 
71  void onDnsLookupCompleted(
72  unsigned int timeoutMs,
73  IpAddress ipAddress,
74  ExceptionPtr e);
75 
76  void setupSocket();
77  void setupSocket(Exception & e);
78 
79  friend class HttpFrameFilter;
80 
81  // Address of the RcfServer.
82  IpAddress mServerAddr;
83 
84  // Actual network address we connect to. May be the same as mServerAddr,
85  // but could also be the address of a HTTP proxy.
86  IpAddress mConnectionAddr;
87  };
88 
89 } // namespace RCF
90 
91 #endif // ! INCLUDE_RCF_TCPCLIENTTRANSPORT_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:24
TransportType
Describes the transport types used by a RCF connection.
Definition: Enums.hpp:34