| 98 | } |
| 99 | |
| 100 | void LCDConnection::send(const string &toSend) { |
| 101 | const string s = toSend + "\r\n"; |
| 102 | |
| 103 | #ifdef DEBUG |
| 104 | cerr << "Sending : " << s << endl; |
| 105 | #endif // DEBUG |
| 106 | |
| 107 | if (!_isConnected) { |
| 108 | throw LCDException(LCD_SOCKET_NOT_CONNECTED); |
| 109 | } |
| 110 | |
| 111 | const int total = s.size(); |
| 112 | int offset = 0; |
| 113 | |
| 114 | while (offset != total) { |
| 115 | const int sent = ::send(_sock, s.c_str() + offset, total - offset, 0); |
| 116 | if ( ((sent == -1) && (errno != EAGAIN)) || (sent == 0) ) { |
| 117 | throw LCDException(LCD_SOCKET_SEND_ERROR); |
| 118 | } else { |
| 119 | offset += sent; |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | string LCDConnection::recv() { |
| 125 | if (!_isConnected) { |
nothing calls this directly
no test coverage detected