aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-02-19 19:05:41 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-02-19 19:06:42 +0100
commita3342d096f3456e5e8d087bb3c8eea8b25eb6b57 (patch)
tree593c21e6c05cd92079831784f436bdf4ca653e70
parente0b8d459b189ee2b7e95a47b217e4b02bfb523b3 (diff)
downloadbitcoin-a3342d096f3456e5e8d087bb3c8eea8b25eb6b57.tar.xz
Fix #626: RecvLine wrong error message
Also moved RecvLine to net.cpp.
-rw-r--r--src/irc.cpp51
-rw-r--r--src/irc.h1
-rw-r--r--src/net.cpp51
-rw-r--r--src/net.h1
4 files changed, 52 insertions, 52 deletions
diff --git a/src/irc.cpp b/src/irc.cpp
index e79577269e..7a6f40cfad 100644
--- a/src/irc.cpp
+++ b/src/irc.cpp
@@ -76,57 +76,6 @@ static bool Send(SOCKET hSocket, const char* pszSend)
return true;
}
-bool RecvLine(SOCKET hSocket, string& strLine)
-{
- strLine = "";
- loop
- {
- 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)
- {
- if (fShutdown)
- return false;
- if (nBytes < 0)
- {
- int nErr = WSAGetLastError();
- if (nErr == WSAEMSGSIZE)
- continue;
- if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS)
- {
- Sleep(10);
- continue;
- }
- }
- if (!strLine.empty())
- return true;
- if (nBytes == 0)
- {
- // socket closed
- printf("IRC socket closed\n");
- return false;
- }
- else
- {
- // socket error
- int nErr = WSAGetLastError();
- printf("IRC recv failed: %d\n", nErr);
- return false;
- }
- }
- }
-}
-
bool RecvLineIRC(SOCKET hSocket, string& strLine)
{
loop
diff --git a/src/irc.h b/src/irc.h
index f5adaa1276..08d62b83d2 100644
--- a/src/irc.h
+++ b/src/irc.h
@@ -5,7 +5,6 @@
#ifndef BITCOIN_IRC_H
#define BITCOIN_IRC_H
-bool RecvLine(SOCKET hSocket, std::string& strLine);
void ThreadIRCSeed(void* parg);
extern int nGotIRCAddresses;
diff --git a/src/net.cpp b/src/net.cpp
index fd488ce671..546bc6adc8 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -83,6 +83,57 @@ void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd)
+bool RecvLine(SOCKET hSocket, string& strLine)
+{
+ strLine = "";
+ loop
+ {
+ 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)
+ {
+ if (fShutdown)
+ return false;
+ if (nBytes < 0)
+ {
+ int nErr = WSAGetLastError();
+ if (nErr == WSAEMSGSIZE)
+ continue;
+ if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS)
+ {
+ Sleep(10);
+ continue;
+ }
+ }
+ if (!strLine.empty())
+ return true;
+ if (nBytes == 0)
+ {
+ // socket closed
+ printf("socket closed\n");
+ return false;
+ }
+ else
+ {
+ // socket error
+ int nErr = WSAGetLastError();
+ printf("recv failed: %d\n", nErr);
+ return false;
+ }
+ }
+ }
+}
+
bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const char* pszKeyword, CNetAddr& ipRet)
diff --git a/src/net.h b/src/net.h
index 0a3cf388ec..f4af93a495 100644
--- a/src/net.h
+++ b/src/net.h
@@ -29,6 +29,7 @@ inline unsigned int ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer"
inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 10*1000); }
static const unsigned int PUBLISH_HOPS = 5;
+bool RecvLine(SOCKET hSocket, std::string& strLine);
bool GetMyExternalIP(CNetAddr& ipRet);
bool AddAddress(CAddress addr, int64 nTimePenalty=0, CAddrDB *pAddrDB=NULL);
void AddressCurrentlyConnected(const CService& addr);