|
|
|
@ -157,56 +157,6 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer)
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RecvLine(SOCKET hSocket, string& strLine)
|
|
|
|
|
{
|
|
|
|
|
strLine = "";
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
char c;
|
|
|
|
|
int nBytes = recv(hSocket, &c, 1, 0);
|
|
|
|
|
if (nBytes > 0)
|
|
|
|
|
{
|
|
|
|
|
if (c == '\n')
|
|
|
|
|
continue;
|
|
|
|
|
if (c == '\r')
|
|
|
|
|
return true;
|
|
|
|
|
strLine += c;
|
|
|
|
|
if (strLine.size() >= 9000)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (nBytes <= 0)
|
|
|
|
|
{
|
|
|
|
|
boost::this_thread::interruption_point();
|
|
|
|
|
if (nBytes < 0)
|
|
|
|
|
{
|
|
|
|
|
int nErr = WSAGetLastError();
|
|
|
|
|
if (nErr == WSAEMSGSIZE)
|
|
|
|
|
continue;
|
|
|
|
|
if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS)
|
|
|
|
|
{
|
|
|
|
|
MilliSleep(10);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!strLine.empty())
|
|
|
|
|
return true;
|
|
|
|
|
if (nBytes == 0)
|
|
|
|
|
{
|
|
|
|
|
// socket closed
|
|
|
|
|
LogPrint("net", "socket closed\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// socket error
|
|
|
|
|
int nErr = WSAGetLastError();
|
|
|
|
|
LogPrint("net", "recv failed: %s\n", NetworkErrorString(nErr));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int GetnScore(const CService& addr)
|
|
|
|
|
{
|
|
|
|
|
LOCK(cs_mapLocalHost);
|
|
|
|
|