Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include <ibrcommon/thread/Conditional.h>
00009
00010 #ifndef STOPANDWAIT_H_
00011 #define STOPANDWAIT_H_
00012
00013 namespace ibrcommon
00014 {
00015 class stopandwait
00016 {
00017 public:
00018 stopandwait(const size_t timeout, const size_t maxretry = 0);
00019 virtual ~stopandwait();
00020
00021 void setTimeout(size_t timeout);
00022
00023 protected:
00024 int __send(const char *buffer, const size_t length);
00025 int __recv(char *buffer, size_t &length);
00026
00027 virtual int __send_impl(const char *buffer, const size_t length) = 0;
00028 virtual int __recv_impl(char *buffer, size_t &length) = 0;
00029
00030 private:
00031 size_t _maxretry;
00032 u_int8_t _out_seqno;
00033 u_int8_t _in_seqno;
00034 u_int8_t _ack_seqno;
00035
00036 unsigned int _count;
00037 size_t _timeout;
00038 ibrcommon::Conditional _ack_cond;
00039 };
00040 }
00041
00042 #endif