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