Remote Call Framework 3.3
TimedBsdSockets.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_TIMEDBSDSOCKETS_HPP
19 #define INCLUDE_RCF_TIMEDBSDSOCKETS_HPP
20 
21 #include <vector>
22 
23 #include <RCF/ClientProgress.hpp>
24 #include <RCF/Export.hpp>
25 #include <RCF/BsdSockets.hpp> // GetErrorString()
26 #include <RCF/RcfFwd.hpp>
27 
28 namespace RCF {
29 
30  class ByteBuffer;
31 
32  class I_PollingFunctor
33  {
34  public:
35  virtual ~I_PollingFunctor() {}
36  virtual int operator()(int, int &, bool) = 0;
37  };
38 
39  class PollingFunctor : public I_PollingFunctor
40  {
41  public:
42  PollingFunctor(
43  ClientProgressPtr clientProgressPtr,
44  RemoteCallPhase activity,
45  unsigned int endTimeMs);
46 
47  int operator()(int fd, int &err, bool bRead);
48 
49  private:
50  ClientProgressPtr mClientProgressPtr;
51  RemoteCallPhase mActivity;
52  unsigned int mEndTimeMs;
53  };
54 
55  // return -2 for timeout, -1 for error, 0 for ready
56  RCF_EXPORT int pollSocket(
57  unsigned int endTimeMs,
58  int fd,
59  int &err,
60  bool bRead);
61 
62  // return -2 for timeout, -1 for error, 0 for ready
63  RCF_EXPORT int pollSocketWithProgress(
64  ClientProgressPtr ClientProgressPtr,
65  RemoteCallPhase activity,
66  unsigned int endTimeMs,
67  int fd,
68  int &err,
69  bool bRead);
70 
71  //******************************************************
72  // nonblocking socket routines
73 
74  // returns -2 for timeout, -1 for error, otherwise 0
75  RCF_EXPORT int timedConnect(
76  I_PollingFunctor &pollingFunctor,
77  int &err,
78  int fd,
79  const sockaddr *addr,
80  int addrLen);
81 
82  // returns -2 for timeout, -1 for error, otherwise number of bytes sent (> 0)
83  RCF_EXPORT int timedSend(
84  I_PollingFunctor &pollingFunctor,
85  int &err,
86  int fd,
87  const std::vector<ByteBuffer> &byteBuffers,
88  std::size_t maxSendSize,
89  int flags);
90 
91  class BsdClientTransport;
92 
93  // returns -2 for timeout, -1 for error, 0 for peer closure, otherwise size of packet read
94  RCF_EXPORT int timedRecv(
95  BsdClientTransport &clientTransport,
96  I_PollingFunctor &pollingFunctor,
97  int &err,
98  int fd,
99  const ByteBuffer &byteBuffer,
100  std::size_t bytesRequested,
101  int flags);
102 
103  RCF_EXPORT bool isFdConnected(int fd);
104 
105  RCF_EXPORT std::pair<std::string, std::vector<std::string> > getLocalIps();
106 
107 } // namespace RCF
108 
109 
110 #endif // ! INCLUDE_RCF_TIMEDBSDSOCKETS_HPP
Definition: AmiIoHandler.hpp:23
RemoteCallPhase
Describes which activity a remote call is currently in.
Definition: Enums.hpp:182