| 122 | } |
| 123 | |
| 124 | string LCDConnection::recv() { |
| 125 | if (!_isConnected) { |
| 126 | throw LCDException(LCD_SOCKET_NOT_CONNECTED); |
| 127 | } |
| 128 | |
| 129 | char buf[LCD_MAXRECV + 1]; |
| 130 | memset(buf, 0, LCD_MAXRECV + 1); |
| 131 | |
| 132 | for (char* current = buf; current < (buf + LCD_MAXRECV); ++current) { |
| 133 | const int status = ::recv(_sock, current, 1, 0); |
| 134 | if (-1 == status) { |
| 135 | throw LCDException(LCD_SOCKET_RECV_ERROR); |
| 136 | } |
| 137 | if (('\0' == *current) || ('\r' == *current) || ('\n' == *current)) { |
| 138 | *current = '\0'; // N.B. Delete line termination character |
| 139 | break; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | const string result(buf); |
| 144 | |
| 145 | #ifdef DEBUG |
| 146 | cerr << "Receiving : " << result << endl; |
| 147 | #endif // DEBUG |
| 148 | |
| 149 | return result; |
| 150 | } |
| 151 | |
| 152 | const LCDConnection& LCDConnection::operator <<(const string &s) { |
| 153 | send(s); |
nothing calls this directly
no test coverage detected