MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / recv

Method recv

src/server/lcdapi/api/LCDConnection.cpp:124–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124string 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
152const LCDConnection& LCDConnection::operator <<(const string &s) {
153 send(s);

Callers

nothing calls this directly

Calls 1

LCDExceptionClass · 0.85

Tested by

no test coverage detected