#ifndef __JNET__JSOCKETSTATUS__ #define __JNET__JSOCKETSTATUS__ #include "JLang/JException.hh" /** * \author mdejong */ namespace JNET {} namespace JPP { using namespace JNET; } namespace JNET { using JLANG::JSocketException; /** * Auxiliary class for non-blocking socket I/O. */ class JSocketStatus { public: enum JStatus_t { IO_RESET = -1, IO_READY = 0, IO_BUSY = +1 }; /** * Default constructor. */ JSocketStatus() : status (IO_RESET), counter(0) {} /** * Get status of I/O. * * \return status */ JStatus_t getStatus() const { return status; } /** * Check reset status. * * \return true if reset; else false */ bool isReset() const { return status == IO_RESET; } /** * Check busy status. * * \return true if busy; else false */ bool isBusy() const { return status == IO_BUSY; } /** * Check ready status. * * \return true if ready; else false */ bool isReady() const { return status == IO_READY; } /** * Get number of I/O attempts. * * \return number of I/O attempts */ int getCounter() const { return counter; } /** * Reset */ void reset() { status = IO_RESET; counter = 0; } protected: /** * Set status of I/O. * * \param status status */ void setStatus(const JStatus_t status) { this->status = status; } JStatus_t status; int counter; }; } #endif