00001 #ifndef _LCD_CONNECTION_H_ 00002 #define _LCD_CONNECTION_H_ 00003 00004 #include <sys/types.h> 00005 #include <sys/socket.h> 00006 #include <netinet/in.h> 00007 #include <netdb.h> 00008 #include <unistd.h> 00009 #include <string> 00010 #include <arpa/inet.h> 00011 00012 00013 class LCDConnection 00014 { 00015 private: 00016 bool _isConnected; 00017 int _sock; 00018 sockaddr_in _addr; 00019 00020 public: 00021 LCDConnection(); 00022 LCDConnection(const std::string &host, const int port); 00023 LCDConnection(const LCDConnection &source); 00024 virtual ~LCDConnection(); 00025 00026 bool isValid() const; 00027 00028 void connect(const std::string &host, const int port); 00029 void disconnect(); 00030 00031 void send(const std::string &toSend); 00032 std::string recv(); 00033 00034 LCDConnection & operator = (const LCDConnection ©); 00035 const LCDConnection & operator << (const std::string &s); 00036 const LCDConnection & operator >> (std::string &s); 00037 00038 }; 00039 00040 00041 #endif 00042