Jpp  17.3.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSocketStatus.hh
Go to the documentation of this file.
1 #ifndef __JNET__JSOCKETSTATUS__
2 #define __JNET__JSOCKETSTATUS__
3 
4 #include "JLang/JException.hh"
5 
6 
7 /**
8  * \author mdejong
9  */
10 
11 namespace JNET {}
12 namespace JPP { using namespace JNET; }
13 
14 namespace JNET {
15 
17 
18 
19  /**
20  * Auxiliary class for non-blocking socket I/O.
21  */
23  {
24  public:
25 
26  enum JStatus_t { IO_RESET = -1, IO_READY = 0, IO_BUSY = +1 };
27 
28 
29  /**
30  * Default constructor.
31  */
33  status (IO_RESET),
34  counter(0)
35  {}
36 
37 
38  /**
39  * Get status of I/O.
40  *
41  * \return status
42  */
44  {
45  return status;
46  }
47 
48 
49  /**
50  * Check reset status.
51  *
52  * \return true if reset; else false
53  */
54  bool isReset() const
55  {
56  return status == IO_RESET;
57  }
58 
59 
60  /**
61  * Check busy status.
62  *
63  * \return true if busy; else false
64  */
65  bool isBusy() const
66  {
67  return status == IO_BUSY;
68  }
69 
70 
71  /**
72  * Check ready status.
73  *
74  * \return true if ready; else false
75  */
76  bool isReady() const
77  {
78  return status == IO_READY;
79  }
80 
81 
82  /**
83  * Get number of I/O attempts.
84  *
85  * \return number of I/O attempts
86  */
87  int getCounter() const
88  {
89  return counter;
90  }
91 
92 
93  /**
94  * Reset
95  */
96  void reset()
97  {
98  status = IO_RESET;
99  counter = 0;
100  }
101 
102 
103  protected:
104  /**
105  * Set status of I/O.
106  *
107  * \param status status
108  */
110  {
111  this->status = status;
112  }
113 
114 
116  int counter;
117  };
118 }
119 
120 #endif
Exceptions.
void setStatus(const JStatus_t status)
Set status of I/O.
JSocketStatus()
Default constructor.
void reset()
Reset.
JStatus_t getStatus() const
Get status of I/O.
int getCounter() const
Get number of I/O attempts.
bool isReady() const
Check ready status.
bool isReset() const
Check reset status.
Exception for socket.
Definition: JException.hh:450
Auxiliary class for non-blocking socket I/O.
bool isBusy() const
Check busy status.