MCPcopy Create free account
hub / github.com/LUX-Core/lux / RecvLine

Function RecvLine

src/net.cpp:193–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193bool RecvLine(SOCKET hSocket, string& strLine)
194{
195 strLine = "";
196 while (true) {
197 char c;
198 int nBytes = recv(hSocket, &c, 1, 0);
199 if (nBytes > 0) {
200 if (c == '\n')
201 continue;
202 if (c == '\r')
203 return true;
204 strLine += c;
205 if (strLine.size() >= 9000)
206 return true;
207 } else if (nBytes <= 0) {
208 boost::this_thread::interruption_point();
209 if (nBytes < 0) {
210 int nErr = WSAGetLastError();
211 if (nErr == WSAEMSGSIZE)
212 continue;
213 if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS) {
214 MilliSleep(10);
215 continue;
216 }
217 }
218 if (!strLine.empty())
219 return true;
220 if (nBytes == 0) {
221 // socket closed
222 LogPrint("net", "socket closed\n");
223 return false;
224 } else {
225 // socket error
226 int nErr = WSAGetLastError();
227 LogPrint("net", "recv failed: %s\n", NetworkErrorString(nErr));
228 return false;
229 }
230 }
231 }
232}
233
234int GetnScore(const CService& addr)
235{

Callers

nothing calls this directly

Calls 5

MilliSleepFunction · 0.85
LogPrintFunction · 0.85
NetworkErrorStringFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected