| 191 | } |
| 192 | |
| 193 | bool 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 | |
| 234 | int GetnScore(const CService& addr) |
| 235 | { |
nothing calls this directly
no test coverage detected