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