typedef unsigned char byte; class Comm { public: enum CommStatus { COMM_ERR = 0, COMM_OK = 1, COMM_NULL = 2 }; int fd; CommStatus open(); CommStatus send(const byte *const data, const unsigned len); CommStatus recvbyte(byte *const data); CommStatus recv(byte* data, int size); Comm() : fd(-1) {} ~Comm() { if (fd != -1) close(fd); fd = -1; } };